@Override
  public long getTotalIntervalNum() {
    long queryRange = endTime - startTime;
    long intervalNum;

    if (slidingStep.containsMonth()) {
      intervalNum =
          (long)
              Math.ceil(
                  (double) queryRange
                      / (slidingStep.getMaxTotalDuration(TimestampPrecisionUtils.currPrecision)));
      long retStartTime =
          DateTimeUtils.calcPositiveIntervalByMonth(
              startTime, slidingStep.multiple(intervalNum), zoneId);
      while (retStartTime < endTime) {
        intervalNum++;
        retStartTime =
            DateTimeUtils.calcPositiveIntervalByMonth(
                startTime, slidingStep.multiple(intervalNum), zoneId);
      }
    } else {
      intervalNum = (long) Math.ceil(queryRange / (double) slidingStep.nonMonthDuration);
    }
    return intervalNum;
  }
This class iteratively generates aggregated time windows.

<p>For example, startTime = 0, endTime = 10, interval = 5, slidingStep = 3, leftCloseRightOpen,
return [0,5],[3,7],[6,9],[9,9]
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/AggrWindowIterator.java