Skip to content

[IoTDB-468] Restructure QueryPlan#796

Merged
qiaojialin merged 6 commits into
apache:new_series_readerfrom
Alima777:new_series_reader
Feb 13, 2020
Merged

[IoTDB-468] Restructure QueryPlan#796
qiaojialin merged 6 commits into
apache:new_series_readerfrom
Alima777:new_series_reader

Conversation

@Alima777
Copy link
Copy Markdown
Contributor

@Alima777 Alima777 commented Feb 12, 2020

The AlignByDevice query ( which is called groupByDevice before ) and general query aligning by time are both storaged in QueryPlan now. However, they invoke different query process bascially, so it's necessary to restructure the QueryPlan and seperate the AlignByDeviceQuery from it.

The QueryPlan is designed as base class, which has RawDataQueryPlan and AlignByDevicePlan as subclasses. This restructure may bring some usage changes, because the general query which uses QueryPlan directly before has to instantiate RawDataQueryPlan now.

If you think the design is not friendly to users, welcome to comment.

@Alima777 Alima777 requested a review from qiaojialin February 12, 2020 06:38
Copy link
Copy Markdown
Member

@qiaojialin qiaojialin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The QueryPlan looks nice now.


public class AlignByDevicePlan extends QueryPlan {

private List<String> measurements; // for group by device sql, e.g. temperature
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private List<String> measurements; // for group by device sql, e.g. temperature
private List<String> measurements; // e.g. temperature

give a more complex example, such as m1, m2, m3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this measurements with the paths in QueryPlan?
Refactor the organization or rename this field

Copy link
Copy Markdown
Contributor Author

@Alima777 Alima777 Feb 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the paths in QueryPlan are paths of all devices. It's for verification and complete DataTypeMap to execute the datatypes for the execution paths this time in DataSet.

Comment thread server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java Outdated

private List<String> measurements; // for group by device sql, e.g. temperature
private Map<String, Set<String>> deviceToMeasurementsMap; // for group by device sql, e.g. root.ln.d1 -> temperature
private Map<String, TSDataType> dataTypeConsistencyChecker; // for group by device sql, e.g. root.ln.d1.temperature -> Float
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private Map<String, TSDataType> dataTypeConsistencyChecker; // for group by device sql, e.g. root.ln.d1.temperature -> Float
private Map<String, TSDataType> seriesTypeMap; // e.g. root.ln.d1.temperature -> Float

make the field name clear

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to explain it.


private GroupByPlan groupByPlan;
private FillQueryPlan fillQueryPlan;
private AggregationPlan aggregationPlan;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why there isn't a RawDataQueryPan

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course there isn't a RawDataQueryPan. We don't need parameters in it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but you need to do a RawData query for each device a

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a RawDataQueryPlan in AlignByDeviceDataSet.

//the measurements that have quotation mark. e.g., "abc",
// '11', the data type is considered as String and the value is considered is the same with measurement name
private List<String> constMeasurements = new ArrayList<>(); // for group by device sql
private List<Integer> positionOfConstMeasurements = new ArrayList<>(); // for group by device sql
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put fields in the front of the class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

this.constMeasurements = alignByDevicePlan.getConstMeasurements();
this.positionOfNotExistMeasurements = alignByDevicePlan.getPositionOfNotExistMeasurements();
this.positionOfConstMeasurements = alignByDevicePlan.getPositionOfConstMeasurements();
//BuildOutDataTypes();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

} else if (queryPlan instanceof FillQueryPlan) {
} else if (alignByDevicePlan.getFillQueryPlan() != null) {
this.dataSetType = DataSetType.FILL;
// assign parameters
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

//BuildOutDataTypes();

if (queryPlan instanceof GroupByPlan) {
if (alignByDevicePlan.getGroupByPlan() != null) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a queryType in AlignByDevicePlan, and use switch here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

break;
case QUERY:
QueryPlan queryPlan = new QueryPlan();
RawDataQueryPlan queryPlan = new RawDataQueryPlan();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you save three plans in AlignByDevicePlan? They could be reused

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Idea. Fixed.

Comment thread server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java Outdated

private GroupByPlan groupByPlan;
private FillQueryPlan fillQueryPlan;
private AggregationPlan aggregationPlan;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but you need to do a RawData query for each device a

super();
}

public AlignByDevicePlan(boolean isQuery, Operator.OperatorType operatorType) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this unused

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


public class GroupByPlan extends AggregationPlan {
public class
GroupByPlan extends AggregationPlan {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...Fixed.


public class GroupByPlan extends AggregationPlan {
public class
GroupByPlan extends AggregationPlan {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GroupByPlan extends AggregationPlan {
GroupByTimePlan extends AggregationPlan {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep it.


private boolean isGroupByDevice = false;
private boolean isAlign = true;
private boolean isAlignByDevice = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private boolean isAlignByDevice = false;
private boolean alignByDevice = false;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep it.

private boolean isGroupByDevice = false;
private boolean isAlign = true;
private boolean isAlignByDevice = false;
private boolean isAlignByTime = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private boolean isAlignByTime = true;
private boolean alignByTime = true;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep it please.



/**
* This QueryDataSet is used for GROUP_BY_DEVICE query result.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* This QueryDataSet is used for GROUP_BY_DEVICE query result.
* This QueryDataSet is used for align by device query result.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -80,45 +77,41 @@ public class DeviceIterateDataSet extends QueryDataSet {
private int[] currentColumnMapRelation;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about renaming this class to AlignByDeviceDataset

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice. I will rename it.

break;
default:
this.dataSetType = DataSetType.QUERY;
this.rawDataQueryPlan = new RawDataQueryPlan();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is a little strange

@qiaojialin qiaojialin merged commit 753239a into apache:new_series_reader Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants