Skip to content

[IOTDB-340/339] Remove unnecessary getting data types from MManager #677

Merged
qiaojialin merged 12 commits intoapache:masterfrom
liutaohua:remove_mmanager_for_query
Dec 28, 2019
Merged

[IOTDB-340/339] Remove unnecessary getting data types from MManager #677
qiaojialin merged 12 commits intoapache:masterfrom
liutaohua:remove_mmanager_for_query

Conversation

@liutaohua
Copy link
Copy Markdown
Contributor

In a QueryPlan, the selected paths with data types, predicates (expression) are included.

private List paths;
private List dataTypes;
private IExpression expression;
However, when executing a QueryPlan in the AbstractQueryProcessExecutor, only paths and expression are passed to the EngineQueryRouter through QueryExpression.

Therefore, the data type information is lost and needs to get from manager again, which is a waste.

It's better to pass the full QueryPlan to the EngineQueryRouter for all query types: raw data query, fill query, group by query, aggregation query.

The QueryExpression is a parameter in the query interface of TsFile, we do not need to use it in the server, because we could get more information on the server.

liudw added 2 commits December 27, 2019 11:12
…to remove_mmanager_for_query

� Conflicts:
�	server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
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.

Good work! just some optimizations

import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.iotdb.hadoop.fileSystem.HDFSInput;
import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
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

deduplicatedAggregations);
queryDataSet = aggregate(deduplicatedPaths, deduplicatedAggregations,
queryPlan.getExpression(),
return groupBy(groupByPlan.getDeduplicatedPaths(), groupByPlan.getDeduplicatedDataTypes(),
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.

I prefer to replace the parameter to a GroupByPlan

groupByPlan.getStartTime(), groupByPlan.getEndTime(),
context);
} else if (queryPlan instanceof AggregationPlan) {
queryDataSet = aggregate(queryPlan.getDeduplicatedPaths(),
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.

also, change the parameter of methods in IQueryProcesExecutor to a certain Plan


private List<Path> deduplicatedPaths = null;
private List<TSDataType> deduplicatedDataTypes = null;
private List<String> deduplicatedAggregations = new ArrayList<>();
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.

move this to AggregationPlan

} else {
deduplicate(queryPlan);
}
if (queryPlan.getDeduplicatedPaths() == 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.

The following 3 if could be avoided

List<String> aggregations = queryPlan.getAggregations();

Map<Path, TSDataType> dataTypeMapping = queryPlan.getDataTypeMapping();
if (paths == 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.

This could also be removed.
If the user selects some non-existing paths, the ConcatPathOptimizer will throw an exception.

private void deduplicate(QueryPlan queryPlan)
throws QueryProcessException {
List<Path> paths = queryPlan.getPaths();
if (paths == 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.

remove this also

private List<Path> deduplicatedPaths = null;
private List<TSDataType> deduplicatedDataTypes = null;
private List<String> deduplicatedAggregations = new ArrayList<>();
private Map<Path, TSDataType> dataTypeMapping = new HashMap<>();
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 field may be useless, you can use deduplicatedPaths and deduplicatedDataTypes.

public void initGroupBy(QueryContext context, List<String> aggres, IExpression expression)
throws StorageEngineException, QueryProcessException, IOException {
initAggreFuction(aggres);
public void initGroupBy(QueryContext context, List<String> aggres, List<TSDataType> dataTypes,
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.

change this to a private method that called in GroupByWithValueFilterDataSet constructor

* init reader and aggregate function.
*/
public void initGroupBy(QueryContext context, List<String> aggres, IExpression expression)
public void initGroupBy(QueryContext context, List<String> aggres, List<TSDataType> dataTypes,
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.

Change this to a private method and called in constructor. More, the constructor could receive a GroupByPlan as a parameter, which is clearer

@qiaojialin
Copy link
Copy Markdown
Member

Could the deduplicated codes be removed in IoTDBQueryResultSet? Just use the deduplicated paths passed by server

@qiaojialin qiaojialin merged commit 2200115 into apache:master Dec 28, 2019
@qiaojialin qiaojialin changed the title [IOTDB-340] Remove unnecessary getting data types from MManager [IOTDB-340/339] Remove unnecessary getting data types from MManager Dec 28, 2019
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