liuminghui233 commented on code in PR #7277:
URL: https://github.com/apache/iotdb/pull/7277#discussion_r970854235


##########
server/src/main/java/org/apache/iotdb/db/mpp/aggregation/Accumulator.java:
##########
@@ -18,20 +18,20 @@
  */
 package org.apache.iotdb.db.mpp.aggregation;
 
+import org.apache.iotdb.db.mpp.execution.operator.window.IWindow;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.statistics.Statistics;
-import org.apache.iotdb.tsfile.read.common.TimeRange;
 import org.apache.iotdb.tsfile.read.common.block.column.Column;
 import org.apache.iotdb.tsfile.read.common.block.column.ColumnBuilder;
 
 public interface Accumulator {
 
   /**
-   * Column should be like: | Time | Value |
+   * Column should be like: | ControlColumn | Value |

Review Comment:
   As far as I'm concerned, this input should contain three columns
   ```suggestion
      * Column should be like: | ControlColumn | Time | Value |
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/SlidingWindowAggregationOperator.java:
##########
@@ -29,10 +29,15 @@
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static 
org.apache.iotdb.db.mpp.execution.operator.AggregationUtil.appendAggregationResult;
 import static 
org.apache.iotdb.db.mpp.execution.operator.AggregationUtil.initTimeRangeIterator;
 
 public class SlidingWindowAggregationOperator extends 
SingleInputAggregationOperator {
 
+  protected final ITimeRangeIterator timeRangeIterator;
+  // current interval of aggregation window [curStartTime, curEndTime)
+  protected TimeRange curTimeRange;

Review Comment:
   ```suggestion
     private TimeRange curTimeRange;
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/SlidingWindowAggregationOperator.java:
##########
@@ -29,10 +29,15 @@
 import java.util.List;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static 
org.apache.iotdb.db.mpp.execution.operator.AggregationUtil.appendAggregationResult;
 import static 
org.apache.iotdb.db.mpp.execution.operator.AggregationUtil.initTimeRangeIterator;
 
 public class SlidingWindowAggregationOperator extends 
SingleInputAggregationOperator {
 
+  protected final ITimeRangeIterator timeRangeIterator;

Review Comment:
   ```suggestion
     private final ITimeRangeIterator timeRangeIterator;
   ```



##########
server/src/main/java/org/apache/iotdb/db/mpp/aggregation/Aggregator.java:
##########
@@ -63,22 +65,18 @@ public int processTsBlock(TsBlock tsBlock) {
     checkArgument(
         step.isInputRaw(),
         "Step in SeriesAggregateScanOperator and RawDataAggregateOperator can 
only process raw input");
-    if (inputLocationList == null) {
-      return accumulator.addInput(tsBlock.getTimeAndValueColumn(0), 
curTimeRange);
-    } else {
-      int lastReadReadIndex = 0;
-      for (InputLocation[] inputLocations : inputLocationList) {
-        checkArgument(
-            inputLocations[0].getTsBlockIndex() == 0,
-            "RawDataAggregateOperator can only process one tsBlock input.");
-        Column[] timeValueColumn = new Column[2];
-        timeValueColumn[0] = tsBlock.getTimeColumn();
-        timeValueColumn[1] = 
tsBlock.getColumn(inputLocations[0].getValueColumnIndex());
-        lastReadReadIndex =
-            Math.max(lastReadReadIndex, accumulator.addInput(timeValueColumn, 
curTimeRange));
-      }
-      return lastReadReadIndex;
+    int lastReadReadIndex = 0;
+    for (InputLocation[] inputLocations : inputLocationList) {
+      checkArgument(
+          inputLocations[0].getTsBlockIndex() == 0,
+          "RawDataAggregateOperator can only process one tsBlock input.");
+      Column[] controlAndValueColumn = new Column[2];

Review Comment:
   seem as above



##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/SingleInputAggregationOperator.java:
##########
@@ -91,9 +83,8 @@ public ListenableFuture<?> isBlocked() {
     return child.isBlocked();
   }
 
-  @Override
-  public boolean hasNext() {
-    return curTimeRange != null || timeRangeIterator.hasNextTimeRange();
+  protected boolean hasMoreData() {

Review Comment:
   This method seems to be only used in RawDataAggregationOperator.



##########
server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/window/TimeWindow.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+package org.apache.iotdb.db.mpp.execution.operator.window;
+
+import org.apache.iotdb.db.mpp.aggregation.Accumulator;
+import org.apache.iotdb.tsfile.read.common.TimeRange;
+import org.apache.iotdb.tsfile.read.common.block.TsBlock;
+import org.apache.iotdb.tsfile.read.common.block.column.Column;
+import org.apache.iotdb.tsfile.read.common.block.column.TimeColumn;
+
+public class TimeWindow implements IWindow {
+
+  private TimeRange curTimeRange;
+
+  public TimeWindow() {}
+
+  public TimeWindow(TimeRange curTimeRange) {
+    this.curTimeRange = curTimeRange;
+  }
+
+  public TimeRange getCurTimeRange() {
+    return curTimeRange;
+  }
+
+  public long getCurMinTime() {
+    return curTimeRange.getMin();
+  }
+
+  public long getCurMaxTime() {
+    return curTimeRange.getMax();
+  }
+
+  @Override
+  public Column getControlColumn(TsBlock tsBlock) {
+    return tsBlock.getTimeColumn();
+  }
+
+  @Override
+  public boolean satisfy(Column column, int index) {
+    long curTime = column.getLong(index);
+    return curTime <= getCurMaxTime() && curTime >= getCurMinTime();
+  }
+
+  @Override
+  public boolean isTimeWindow() {

Review Comment:
   remove it



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to