private static void serializeTsBlock(
      int rowCount,
      int currentCount,
      TsBlock tsBlock,
      int columnNum,
      DataOutputStream[] dataOutputStreams,
      int[] valueOccupation,
      int[] bitmaps)
      throws IOException {
    // serialize time column
    for (int i = 0; i < currentCount; i++) {
      // use columnOutput to write byte array
      dataOutputStreams[0].writeLong(tsBlock.getTimeByIndex(i));
    }

    // serialize each value column and its bitmap
    for (int k = 0; k < columnNum; k++) {
      // get DataOutputStream for current value column and its bitmap
      DataOutputStream dataOutputStream = dataOutputStreams[2 * k + 1];
      DataOutputStream dataBitmapOutputStream = dataOutputStreams[2 * (k + 1)];

      Column column = tsBlock.getColumn(k);
      TSDataType type = column.getDataType();
      switch (type) {
        case INT32:
        case DATE:
          doWithInt32Column(
              rowCount,
              column,
              bitmaps,
              k,
              dataOutputStream,
              valueOccupation,
              dataBitmapOutputStream);
          break;
        case INT64:
        case TIMESTAMP:
          doWithInt64Column(
              rowCount,
              column,
              bitmaps,
              k,
              dataOutputStream,
              valueOccupation,
              dataBitmapOutputStream);
          break;
        case FLOAT:
          doWithFloatColumn(
              rowCount,
              column,
              bitmaps,
              k,
              dataOutputStream,
              valueOccupation,
              dataBitmapOutputStream);
          break;
        case DOUBLE:
          doWithDoubleColumn(
              rowCount,
              column,
              bitmaps,
              k,
              dataOutputStream,
              valueOccupation,
              dataBitmapOutputStream);
          break;
        case BOOLEAN:
          doWithBooleanColumn(
              rowCount,
              column,
              bitmaps,
              k,
              dataOutputStream,
              valueOccupation,
              dataBitmapOutputStream);
          break;
        case TEXT:
        case BLOB:
        case STRING:
          doWithTextColumn(
              rowCount,
              column,
              bitmaps,
              k,
              dataOutputStream,
              valueOccupation,
              dataBitmapOutputStream);
          break;
        default:
          throw new UnSupportedDataTypeException(
              String.format("Data type %s is not supported.", type));
      }
    }
  }
TimeValuePairUtils to convert between thrift format and TsFile format.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java