You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/07/17 05:46:11 UTC
[incubator-iotdb] branch master updated: improve group by
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 0c167bb improve group by
0c167bb is described below
commit 0c167bbd2f3361d671364ef6bc7a2a8b35d5aa12
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Fri Jul 17 12:23:58 2020 +0800
improve group by
---
.../query/dataset/groupby/LocalGroupByExecutor.java | 19 +++++++++++++++----
.../apache/iotdb/tsfile/read/common/BatchData.java | 13 +++++++++++++
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java
index 3fe555d..3ccd596 100644
--- a/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/query/dataset/groupby/LocalGroupByExecutor.java
@@ -42,12 +42,16 @@ import java.util.Set;
public class LocalGroupByExecutor implements GroupByExecutor {
- private IAggregateReader reader;
+ private final IAggregateReader reader;
private BatchData preCachedData;
// Aggregate result buffer of this path
- private List<AggregateResult> results = new ArrayList<>();
- private TimeRange timeRange;
+ private final List<AggregateResult> results = new ArrayList<>();
+ private final TimeRange timeRange;
+
+ // used for resetting the batch data to the last index
+ private int lastReadCurArrayIndex;
+ private int lastReadCurListIndex;
private QueryDataSource queryDataSource;
@@ -62,6 +66,8 @@ public class LocalGroupByExecutor implements GroupByExecutor {
timeFilter, null, fileFilter);
this.preCachedData = null;
timeRange = new TimeRange(Long.MIN_VALUE, Long.MAX_VALUE);
+ lastReadCurArrayIndex = 0;
+ lastReadCurListIndex = 0;
}
public boolean isEmpty() {
@@ -103,7 +109,7 @@ public class LocalGroupByExecutor implements GroupByExecutor {
continue;
}
// lazy reset batch data for calculation
- batchData.resetBatchData();
+ batchData.resetBatchData(lastReadCurArrayIndex, lastReadCurListIndex);
// skip points that cannot be calculated
while (batchData.hasCurrent() && batchData.currentTime() < curStartTime) {
batchData.next();
@@ -112,6 +118,8 @@ public class LocalGroupByExecutor implements GroupByExecutor {
result.updateResultFromPageData(batchData, curEndTime);
}
}
+ lastReadCurArrayIndex = batchData.getReadCurArrayIndex();
+ lastReadCurListIndex = batchData.getReadCurListIndex();
// can calc for next interval
if (batchData.getMaxTimestamp() >= curEndTime) {
preCachedData = batchData;
@@ -228,6 +236,9 @@ public class LocalGroupByExecutor implements GroupByExecutor {
return true;
}
+ // reset the last position to zero
+ lastReadCurArrayIndex = 0;
+ lastReadCurListIndex = 0;
calcFromBatch(batchData, curStartTime, curEndTime);
// judge whether the calculation finished
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java
index a893c1b..b4d6053 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/BatchData.java
@@ -580,4 +580,17 @@ public class BatchData implements Serializable {
this.readCurArrayIndex = 0;
this.readCurListIndex = 0;
}
+
+ public void resetBatchData(int readCurArrayIndex, int readCurListIndex) {
+ this.readCurArrayIndex = readCurArrayIndex;
+ this.readCurListIndex = readCurListIndex;
+ }
+
+ public int getReadCurListIndex() {
+ return readCurListIndex;
+ }
+
+ public int getReadCurArrayIndex() {
+ return readCurArrayIndex;
+ }
}