jt2594838 commented on code in PR #17665:
URL: https://github.com/apache/iotdb/pull/17665#discussion_r3456566984


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/payload/evolvable/request/PipeTransferPlanNodeReq.java:
##########
@@ -73,15 +79,27 @@ public static PipeTransferPlanNodeReq 
fromTPipeTransferReq(final TPipeTransferRe
   /////////////////////////////// Air Gap ///////////////////////////////
 
   public static byte[] toTPipeTransferBytes(final PlanNode planNode) throws 
IOException {
+    return toTPipeTransferBytes(planNode.serializeToByteBuffer());
+  }
+
+  public static byte[] toTPipeTransferBytes(final ByteBuffer 
serializedPlanNode)
+      throws IOException {
     try (final PublicBAOS byteArrayOutputStream = new PublicBAOS();
         final DataOutputStream outputStream = new 
DataOutputStream(byteArrayOutputStream)) {
       ReadWriteIOUtils.write(IoTDBSinkRequestVersion.VERSION_1.getVersion(), 
outputStream);
       ReadWriteIOUtils.write(PipeRequestType.TRANSFER_PLAN_NODE.getType(), 
outputStream);
       return BytesUtils.concatByteArray(
-          byteArrayOutputStream.toByteArray(), 
planNode.serializeToByteBuffer().array());
+          byteArrayOutputStream.toByteArray(), getBytes(serializedPlanNode));
     }
   }
 
+  private static byte[] getBytes(final ByteBuffer byteBuffer) {
+    final ByteBuffer duplicateBuffer = byteBuffer.duplicate();
+    final byte[] bytes = new byte[duplicateBuffer.remaining()];
+    duplicateBuffer.get(bytes);
+    return bytes;
+  }

Review Comment:
   Is it possible to avoid copying by extending BytesUtils.concatByteArra?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to