Search in sources :

Example 6 with NettyBuffer

use of com.baidu.hugegraph.computer.core.network.buffer.NettyBuffer in project hugegraph-computer by hugegraph.

the class DataMessage method parseWithMemoryBuffer.

/**
 * Decoding uses the given ByteBuf as our data.
 */
public static DataMessage parseWithMemoryBuffer(MessageType type, ByteBuf buf) {
    int requestId = buf.readInt();
    int partition = buf.readInt();
    int bodyLength = buf.readInt();
    // Slice body and retain it, the readIndex of buf will auto to body end
    ByteBuf bodySlice = buf.readRetainedSlice(bodyLength);
    NetworkBuffer networkBuffer = new NettyBuffer(bodySlice);
    return new DataMessage(type, requestId, partition, networkBuffer);
}
Also used : NettyBuffer(com.baidu.hugegraph.computer.core.network.buffer.NettyBuffer) NetworkBuffer(com.baidu.hugegraph.computer.core.network.buffer.NetworkBuffer) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

NettyBuffer (com.baidu.hugegraph.computer.core.network.buffer.NettyBuffer)6 ByteBuf (io.netty.buffer.ByteBuf)6 NetworkBuffer (com.baidu.hugegraph.computer.core.network.buffer.NetworkBuffer)4 Test (org.junit.Test)4 FrameDecoder (com.baidu.hugegraph.computer.core.network.netty.codec.FrameDecoder)3 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 DataMessage (com.baidu.hugegraph.computer.core.network.message.DataMessage)1