public final class DataNettyBuffer extends Object implements DataBuffer
ByteBuf
.Constructor and Description |
---|
DataNettyBuffer(io.netty.buffer.ByteBuf bytebuf,
long length)
Constructor for creating a DataNettyBuffer, by passing a Netty ByteBuf.
|
Modifier and Type | Method and Description |
---|---|
long |
getLength()
Returns the length of the data.
|
Object |
getNettyOutput()
We would not support this method in DataNettyBuffer because this class is only for
reading netty buffers.
|
ByteBuffer |
getReadOnlyByteBuffer()
Returns a
ByteBuffer for read-only access to the data. |
int |
readableBytes() |
void |
readBytes(byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the current
readerIndex and increases the readerIndex
by the number of the transferred bytes (= length ). |
void |
release()
Releases the Netty ByteBuf.
|
public DataNettyBuffer(io.netty.buffer.ByteBuf bytebuf, long length)
release()
must be called after
reading is finished. Otherwise the memory space for the ByteBuf might never be reclaimed.bytebuf
- The ByteBuf having the datalength
- The length of the underlying ByteBuffer datapublic Object getNettyOutput()
UnsupportedOperationException
whenever called.
TODO(qifan): Investigate if using NettyDataBuffer for outgoing message is fine.getNettyOutput
in interface DataBuffer
UnsupportedOperationException
whenever calledpublic long getLength()
DataBuffer
getLength
in interface DataBuffer
public ByteBuffer getReadOnlyByteBuffer()
DataBuffer
ByteBuffer
for read-only access to the data.getReadOnlyByteBuffer
in interface DataBuffer
public void readBytes(byte[] dst, int dstIndex, int length)
DataBuffer
readerIndex
and increases the readerIndex
by the number of the transferred bytes (= length
).readBytes
in interface DataBuffer
dst
- the destinationdstIndex
- the first index of the destinationlength
- the number of bytes to transferpublic int readableBytes()
readableBytes
in interface DataBuffer
public void release()
release
in interface DataBuffer
Copyright © 2023. All Rights Reserved.