@Experimental public interface ByteBufferReadable
ByteBuffer
and its
given position. The interface is borrowed from ByteBufferReadable
and ByteBufferPositionedReadable
in Apache Hadoop.Modifier and Type | Method and Description |
---|---|
int |
read(ByteBuffer byteBuffer)
Reads up to byteBuffer.remaining() bytes into byteBuffer.
|
int |
read(long position,
ByteBuffer byteBuffer)
Reads up to
byteBuffer.remaining() bytes into byteBuffer from a given position in the
file and returns the number of bytes read. |
int read(ByteBuffer byteBuffer) throws IOException
After a successful call, byteBuffer.position() will be advanced by the number of bytes read and byteBuffer.limit() should be unchanged.
In the case of an exception, the values of byteBuffer.position() and byteBuffer.limit() are undefined, and callers should be prepared to recover from this eventuality. Implementations should treat 0-length requests as legitimate, and must not signal an error upon their receipt.
byteBuffer
- the ByteBuffer to receive the results of the read operation.IOException
- if there is some error performing the readint read(long position, ByteBuffer byteBuffer) throws IOException
byteBuffer.remaining()
bytes into byteBuffer from a given position in the
file and returns the number of bytes read. Callers should use byteBuffer.limit(...)
to control the size of the desired read and byteBuffer.position(...)
to control the
offset into the buffer the data should be written to.
After a successful call, byteBuffer.position()
will be advanced by the number of
bytes read and byteBuffer.limit()
will be unchanged.
In the case of an exception, the state of the buffer (the contents of the buffer, the
buf.position()
, the buf.limit()
, etc.) is undefined, and callers should be
prepared to recover from this eventuality.
Implementations should treat 0-length requests as legitimate, and must not signal an error upon their receipt.
position
- position within filebyteBuffer
- the ByteBuffer to receive the results of the read operation.IOException
- if there is some error performing the readCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.