@Override
  public long calculateMaxPeekMemory() {
    long maxPeekMemory = 0;
    long childrenMaxPeekMemory = 0;
    for (Operator child : children) {
      childrenMaxPeekMemory =
          Math.max(childrenMaxPeekMemory, maxPeekMemory + child.calculateMaxPeekMemory());
      maxPeekMemory +=
          (child.calculateMaxReturnSize() + child.calculateRetainedSizeAfterCallingNext());
    }
    // result size + cached TreeMap size
    maxPeekMemory +=
        (calculateMaxReturnSize()
            + TSFileDescriptor.getInstance().getConfig().getMaxTsBlockLineNumber()
                * MAP_NODE_RETRAINED_SIZE);
    return Math.max(maxPeekMemory, childrenMaxPeekMemory);
  }
prepare next batch

@return true if need to break current loop, otherwise false
@throws Exception errors happened while fetching next batch data
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/last/LastQueryMergeOperator.java