private void buildValueChunkWriter(
      final InputStream stream,
      final ChunkHeader chunkHeader,
      final int pageNumber,
      final ValueChunkWriter valueChunkWriter)
      throws IOException, PageException {
    boolean needDecode;
    for (int i = 0; i < pageNumber; i++) {
      needDecode = ReadWriteIOUtils.readBool(stream);
      if (!needDecode) {
        final PageHeader pageHeader =
            PageHeader.deserializeFrom(stream, chunkHeader.getDataType(), true);
        valueChunkWriter.writePageHeaderAndDataIntoBuff(
            ByteBuffer.wrap(ReadWriteIOUtils.readBytesWithSelfDescriptionLength(stream)),
            pageHeader);
        continue;
      }

      // Since there is no data in the time column, we cannot provide the corresponding time for
      // each value.
      // However, if we only need to construct ValueChunk, we only need to provide the start time
      // and end time of each page to construct the statistic. Therefore, when writing data to
      // ValueChunkWriter, first use the wrong time. Before sealing each page, modify the statistic
      // in the page writer and set the correct start time and end time.
      final int length = ReadWriteIOUtils.readInt(stream);
      for (int j = 0; j < length; j++) {
        final boolean isNull = ReadWriteIOUtils.readBool(stream);
        switch (chunkHeader.getDataType()) {
          case INT32:
          case DATE:
            final int int32Value = isNull ? DEFAULT_INT32 : ReadWriteIOUtils.readInt(stream);
            valueChunkWriter.write(0, int32Value, isNull);
            break;
          case INT64:
          case TIMESTAMP:
            final long int64Value = isNull ? DEFAULT_INT64 : ReadWriteIOUtils.readLong(stream);
            valueChunkWriter.write(0, int64Value, isNull);
            break;
          case FLOAT:
            final float floatValue = isNull ? DEFAULT_FLOAT : ReadWriteIOUtils.readFloat(stream);
            valueChunkWriter.write(0, floatValue, isNull);
            break;
          case DOUBLE:
            final double doubleValue =
                isNull ? DEFAULT_DOUBLE : ReadWriteIOUtils.readDouble(stream);
            valueChunkWriter.write(0, doubleValue, isNull);
            break;
          case BOOLEAN:
            final boolean boolValue = isNull ? DEFAULT_BOOLEAN : ReadWriteIOUtils.readBool(stream);
            valueChunkWriter.write(0, boolValue, isNull);
            break;
          case TEXT:
          case BLOB:
          case STRING:
            final Binary binaryValue =
                isNull ? DEFAULT_BINARY : ReadWriteIOUtils.readBinary(stream);
            valueChunkWriter.write(0, binaryValue, isNull);
            break;
          default:
            throw new UnSupportedDataTypeException(
                String.format("Data type %s is not supported.", chunkHeader.getDataType()));
        }
      }
      Statistics<? extends Serializable> statistics =
          valueChunkWriter.getPageWriter().getStatistics();

      // set the correct start time and end time in statistics
      long startTime = ReadWriteIOUtils.readLong(stream);
      long endTime = ReadWriteIOUtils.readLong(stream);
      statistics.setStartTime(startTime);
      statistics.setEndTime(endTime);

      valueChunkWriter.sealCurrentPage();
    }
  }
This class is used to be compatible with the new distribution of aligned series in chunk group.
In past versions, a time chunk and all its corresponding value chunks were continuous within the
chunk group. In order to solve the problem of excessive memory usage during compaction, the value
column is grouped and merged, which will cause the above rules to be broken.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/splitter/BatchedAlignedValueChunkData.java