Package alluxio.grpc
Class ReadableDataBuffer
- java.lang.Object
-
- alluxio.grpc.ReadableDataBuffer
-
- All Implemented Interfaces:
DataBuffer
public class ReadableDataBuffer extends java.lang.Object implements DataBuffer
Class for making wrappingReadableBuffer
asDataBuffer
.
-
-
Constructor Summary
Constructors Constructor Description ReadableDataBuffer(io.grpc.internal.ReadableBuffer buffer)
CreatesDataBuffer
for reading.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getLength()
Returns the length of the data.java.lang.Object
getNettyOutput()
Returns an object for writing to a netty channel.java.nio.ByteBuffer
getReadOnlyByteBuffer()
Returns aByteBuffer
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 currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).void
readBytes(java.io.OutputStream outputStream, int length)
Transfers this buffer's data to the given stream.void
readBytes(java.nio.ByteBuffer outputBuf)
Transfers this buffer's data to the givenByteBuffer
.void
release()
Releases the underlying buffer of this DataBuffer if no longer needed.
-
-
-
Constructor Detail
-
ReadableDataBuffer
public ReadableDataBuffer(io.grpc.internal.ReadableBuffer buffer)
CreatesDataBuffer
for reading.- Parameters:
buffer
- internal buffer
-
-
Method Detail
-
getNettyOutput
public java.lang.Object getNettyOutput()
Description copied from interface:DataBuffer
Returns an object for writing to a netty channel.- Specified by:
getNettyOutput
in interfaceDataBuffer
- Returns:
- the object to output to Netty. Must be ByteBuf or FileRegion
-
getLength
public long getLength()
Description copied from interface:DataBuffer
Returns the length of the data.- Specified by:
getLength
in interfaceDataBuffer
- Returns:
- the length of the data in bytes
-
getReadOnlyByteBuffer
public java.nio.ByteBuffer getReadOnlyByteBuffer()
Description copied from interface:DataBuffer
Returns aByteBuffer
for read-only access to the data.- Specified by:
getReadOnlyByteBuffer
in interfaceDataBuffer
- Returns:
- a read-only ByteBuffer representing the data
-
readBytes
public void readBytes(java.nio.ByteBuffer outputBuf)
Description copied from interface:DataBuffer
Transfers this buffer's data to the givenByteBuffer
.- Specified by:
readBytes
in interfaceDataBuffer
- Parameters:
outputBuf
- the buffer to transfer data to
-
readBytes
public void readBytes(byte[] dst, int dstIndex, int length)
Description copied from interface:DataBuffer
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Specified by:
readBytes
in interfaceDataBuffer
- Parameters:
dst
- the destinationdstIndex
- the first index of the destinationlength
- the number of bytes to transfer
-
readBytes
public void readBytes(java.io.OutputStream outputStream, int length) throws java.io.IOException
Description copied from interface:DataBuffer
Transfers this buffer's data to the given stream.- Specified by:
readBytes
in interfaceDataBuffer
- Parameters:
outputStream
- the stream to transfer data tolength
- length of the data to be transferred- Throws:
java.io.IOException
-
readableBytes
public int readableBytes()
- Specified by:
readableBytes
in interfaceDataBuffer
- Returns:
- the number of readable bytes remaining
-
release
public void release()
Description copied from interface:DataBuffer
Releases the underlying buffer of this DataBuffer if no longer needed.- Specified by:
release
in interfaceDataBuffer
-
-