@Override
  public TsBlock next() throws Exception {

    // end time series for returned TsBlock this time, it's the min/max end time series among all
    // the children
    // TsBlocks order by asc/desc
    Binary currentEndTimeSeries = null;
    boolean init = false;
    // get TsBlock for each input, put their time series into TimeSeriesSelector and then use the
    // min/max TimeSeries
    // among all the input TsBlock as the current output TsBlock's endTimeSeries.
    for (int i = 0; i < inputOperatorsCount; i++) {
      Operator currentChild = children.get(i);
      if (needCallNext(i, currentChild) && prepareNext(i, currentChild)) {
        return null;
      }
      // update the currentEndTimeSeries if the TsBlock is not empty
      if (!empty(i)) {
        Binary endTimeSeries =
            getTimeSeries(inputTsBlocks[i], inputTsBlocks[i].getPositionCount() - 1);
        if (init) {
          currentEndTimeSeries =
              comparator.compare(currentEndTimeSeries, endTimeSeries) < 0
                  ? currentEndTimeSeries
                  : endTimeSeries;
        } else {
          currentEndTimeSeries = endTimeSeries;
          init = true;
        }
      }
    }

    if (timeSeriesSelector.isEmpty()) {
      TsBlock res = tsBlockBuilder.build();
      tsBlockBuilder.reset();
      return res;
    }

    calcCurrentBatch(currentEndTimeSeries);

    clearTsBlockCache(currentEndTimeSeries);

    TsBlock res = tsBlockBuilder.build();
    tsBlockBuilder.reset();
    return res;
  }
Represent whether there are more tsBlocks from ith child operator. If all elements in
noMoreTsBlocks[] are true and inputTsBlocks[] are consumed completely, this operator is
finished.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/last/LastQueryMergeOperator.java