@Override
  public TsBlock next() throws Exception {
    TsBlock res = child.nextWithTimer();
    if (res == null) {
      return null;
    }
    if (res.isEmpty()) {
      return LAST_QUERY_EMPTY_TSBLOCK;
    }

    if (res.getPositionCount() != 1) {
      throw new IllegalArgumentException("last read result should only have one record");
    }

    tsBlockBuilder.reset();
    for (int i = 0; i + 1 < res.getValueColumnCount(); i += 2) {
      MeasurementPath measurementPath =
          new MeasurementPath(
              devicePath.concatNode(seriesPath.getMeasurementList().get(i / 2)),
              seriesPath.getSchemaList().get(i / 2),
              true);
      if (!res.getColumn(i).isNull(0)) {
        long lastTime = res.getColumn(i).getLong(0);
        TsPrimitiveType lastValue = res.getColumn(i + 1).getTsPrimitiveType(0);
        mayUpdateLastCache(lastTime, lastValue, measurementPath);
        appendLastValueToTsBlockBuilder(
            lastTime,
            lastValue,
            measurementPath,
            seriesPath.getSchemaList().get(i / 2).getType().name());
      } else {
        // we still need to update last cache if there is no data for this time series to avoid
        // scanning all files each time
        mayUpdateLastCache(Long.MIN_VALUE, null, measurementPath);
      }
    }
    return !tsBlockBuilder.isEmpty() ? tsBlockBuilder.build() : LAST_QUERY_EMPTY_TSBLOCK;
  }
update last cache for aligned series.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/last/AlignedUpdateLastCacheOperator.java