xumanbu commented on code in PR #906:
URL: https://github.com/apache/incubator-uniffle/pull/906#discussion_r1211058663
##########
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:
In order to keep the uniffle interface design as much as possible, reference
Celeborn&Spark add ManagedBuffer to hold different type ShuffleData(bytebuf or
FileRegion).
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]