You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/03/16 02:41:11 UTC
[GitHub] [incubator-iotdb] samperson1997 commented on a change in pull
request #910: add system design eng files
samperson1997 commented on a change in pull request #910: add system design eng files
URL: https://github.com/apache/incubator-iotdb/pull/910#discussion_r392755681
##########
File path: docs/Documentation/SystemDesign/5-DataQuery/4-AggregationQuery.md
##########
@@ -0,0 +1,114 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+# Aggregation query
+
+The main logic of the aggregation query is in AggregateExecutor
+
+* org.apache.iotdb.db.query.executor.AggregationExecutor
+
+## Aggregation query without value filter
+
+For aggregate queries without value filters, the results are obtained by the `executeWithoutValueFilter ()` method and a dataSet is constructed. First use the `mergeSameSeries ()` method to merge aggregate queries for the same time series. For example: if you need to calculate count (s1), sum (s2), count (s3), sum (s1), you need to calculate two Aggregating the values, then the pathToAggrIndexesMap result will be: s1-> 0, 3; s2-> 1; s3-> 2.
+
+Then you will get `pathToAggrIndexesMap`, where each entry is an aggregate query of series, so you can calculate its aggregate value` aggregateResults` by calling the `groupAggregationsBySeries ()` method. Before you finally create the result set, you need to restore its order to the order of the user query. Finally use the `constructDataSet ()` method to create a result set and return it.
+
+The `groupAggregationsBySeries ()` method is explained in detail below. First create an `IAggregateReader`:
+```
+IAggregateReader seriesReader = new SeriesAggregateReader(
+ pathToAggrIndexes.getKey(), tsDataType, context, QueryResourceManager.getInstance()
+ .getQueryDataSource(seriesPath, context, timeFilter), timeFilter, null);
+```
+
+For each entry (that is, series), first create an aggregate result `AggregateResult` for each aggregate query, and maintain a boolean list` isCalculatedList`, corresponding to whether each `AggregateResult` has been calculated and record the remaining The number of calculated aggregate functions `remainingToCalculate`. The list of boolean values and this count value will make some aggregate functions (such as `FIRST_VALUE`) do not need to continue the entire loop process after obtaining the result.
+
+Next, update AggregateResult according to the usage method of aggregateReader introduced in Section 5.2:
Review comment:
```suggestion
Next, update `AggregateResult` according to the usage method of `aggregateReader` introduced in Section 5.2:
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services