@Override
  public long getTotalIntervalNum() {
    long queryRange = endTime - startTime;
    if (slidingStep >= interval || interval % slidingStep == 0) {
      return (long) Math.ceil(queryRange / (double) slidingStep);
    }

    long interval1 = interval % slidingStep;
    long interval2 = slidingStep - interval % slidingStep;
    long intervalNum = Math.floorDiv(queryRange, interval1 + interval2);
    long tmpStartTime = startTime + intervalNum * (interval1 + interval2);
    if (tmpStartTime + interval1 > endTime) {
      return intervalNum * 2 + 1;
    } else {
      return intervalNum * 2 + 2;
    }
  }
This class iteratively generates pre-aggregated time windows.

<p>For example, startTime = 0, endTime = 11, interval = 5, slidingStep = 3, return
[0,2),[2,3),[3,5),[5,6),[6,8),[8,9),[9,10)
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/aggregation/timerangeiterator/PreAggrWindowIterator.java