public static byte[] toTPipeTransferReqBytes(
      final byte[] rawReqInBytes, final List<PipeCompressor> compressors) throws IOException {
    // The generated bytes consists of:
    // (byte) version
    // (2 bytes) type: TRANSFER_COMPRESSED
    // (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
    try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
        final DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream)) {
      byte[] body = rawReqInBytes;

      ReadWriteIOUtils.write(IoTDBConnectorRequestVersion.VERSION_1.getVersion(), outputStream);
      ReadWriteIOUtils.write(PipeRequestType.TRANSFER_COMPRESSED.getType(), outputStream);
      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);

      return byteArrayOutputStream.toByteArray();
    }
  }
For air-gap connectors. Generate the bytes of a compressed req from the bytes of original req.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/connector/payload/thrift/request/PipeTransferCompressedReq.java