@Override
  public TsBlock next() throws Exception {
    // Start stopwatch
    long maxRuntime = operatorContext.getMaxRunTime().roundTo(TimeUnit.NANOSECONDS);
    long start = System.nanoTime();

    while (System.nanoTime() - start < maxRuntime
        && (curTimeRange != null || timeRangeIterator.hasNextTimeRange())
        && !resultTsBlockBuilder.isFull()) {
      if (!prepareInput()) {
        break;
      }

      if (curTimeRange == null && timeRangeIterator.hasNextTimeRange()) {
        // Move to next time window
        curTimeRange = timeRangeIterator.nextTimeRange();

        // Clear previous aggregation result
        for (TreeAggregator aggregator : aggregators) {
          aggregator.reset();
        }
      }

      // Calculate aggregation result on current time window
      calculateNextAggregationResult();
    }

    if (resultTsBlockBuilder.getPositionCount() > 0) {
      TsBlock resultTsBlock = resultTsBlockBuilder.build();
      resultTsBlockBuilder.reset();
      return resultTsBlock;
    } else {
      return null;
    }
  }
{@link AggregationOperator} can process the situation: aggregation of intermediate aggregate
result, it will output one tsBlock contain many results on aggregation time intervals. One
intermediate tsBlock input will contain the result of many time intervals.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/AggregationOperator.java