You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "jerqi (via GitHub)" <gi...@apache.org> on 2023/05/29 09:35:43 UTC

[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #906: [#590][part-1] ManagedBuffer instead ByteBuf to hold ShuffleData

jerqi commented on code in PR #906:
URL: https://github.com/apache/incubator-uniffle/pull/906#discussion_r1209127405


##########
common/src/main/java/org/apache/uniffle/common/netty/protocol/GetLocalShuffleDataResponse.java:
##########
@@ -18,53 +18,64 @@
 package org.apache.uniffle.common.netty.protocol;
 
 import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
 
+import org.apache.uniffle.common.netty.buffer.FileSegmentManagedBuffer;
+import org.apache.uniffle.common.netty.buffer.ManagedBuffer;
+import org.apache.uniffle.common.netty.buffer.NettyManagedBuffer;
 import org.apache.uniffle.common.rpc.StatusCode;
 import org.apache.uniffle.common.util.ByteBufUtils;
 
-public class GetLocalShuffleDataResponse extends RpcResponse {
-  private ByteBuf data;
+public class GetLocalShuffleDataResponse extends RpcResponse implements Transferable {
 
-  public GetLocalShuffleDataResponse(long requestId, StatusCode statusCode, byte[] data) {
-    this(requestId, statusCode, null, data);
-  }
-
-  public GetLocalShuffleDataResponse(long requestId, StatusCode statusCode, String retMessage, byte[] data) {
-    this(requestId, statusCode, retMessage, Unpooled.wrappedBuffer(data));
-  }
+  private ManagedBuffer buffer;
 
-  public GetLocalShuffleDataResponse(long requestId, StatusCode statusCode, String retMessage, ByteBuf data) {
+  public GetLocalShuffleDataResponse(long requestId, StatusCode statusCode, String retMessage, ManagedBuffer data) {
     super(requestId, statusCode, retMessage);
-    this.data = data;
+    this.buffer = data;
   }
 
   @Override
   public int encodedLength() {
-    return super.encodedLength() + Integer.BYTES + data.readableBytes();
+    return super.encodedLength() + Integer.BYTES + buffer.size();
   }
 
   @Override
   public void encode(ByteBuf buf) {
     super.encode(buf);
-    ByteBufUtils.copyByteBuf(data, buf);
-    data.release();
+    if (buffer instanceof FileSegmentManagedBuffer) {
+      buf.writeInt(buffer.size());

Review Comment:
   Why do we only write the size of buffer?



-- 
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: issues-unsubscribe@uniffle.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org