public static TPipeTransferReq toTPipeTransferReq(
      final TPipeTransferReq originalReq, final List<PipeCompressor> compressors)
      throws IOException {
    // The generated PipeTransferCompressedReq consists of:
    // version
    // type: TRANSFER_COMPRESSED
    // body:
    //   (byte) count of compressors (n)
    //   (n*3 bytes) for each compressor:
    //     (byte) compressor type
    //     (int) length of uncompressed bytes
    //   compressed req:
    //     (byte) version
    //     (2 bytes) type
    //     (bytes) body
    final PipeTransferCompressedReq compressedReq = new PipeTransferCompressedReq();
    compressedReq.version = IoTDBConnectorRequestVersion.VERSION_1.getVersion();
    compressedReq.type = PipeRequestType.TRANSFER_COMPRESSED.getType();

    try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
        final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
      byte[] body =
          BytesUtils.concatByteArrayList(
              Arrays.asList(
                  new byte[] {originalReq.version},
                  BytesUtils.shortToBytes(originalReq.type),
                  originalReq.getBody()));

      ReadWriteIOUtils.write((byte) compressors.size(), outputStream);
      for (final PipeCompressor compressor : compressors) {
        ReadWriteIOUtils.write(compressor.serialize(), outputStream);
        ReadWriteIOUtils.write(body.length, outputStream);
        body = compressor.compress(body);
      }
      outputStream.write(body);

      compressedReq.body =
          ByteBuffer.wrap(byteArrayOutputStream.getBuf(), 0, byteArrayOutputStream.size());
    }
    return compressedReq;
  }
Generate a compressed req with provided compressors.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/payload/thrift/request/PipeTransferCompressedReq.java