Interface ByteBufferReadable
-
- All Known Implementing Classes:
ByteBufferReadableClosingFSDataInputStream
@Experimental public interface ByteBufferReadableAn interface mark that a filesystem supports to read bytes from aByteBufferand its given position. The interface is borrowed fromByteBufferReadableandByteBufferPositionedReadablein Apache Hadoop.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intread(long position, ByteBuffer byteBuffer)Reads up tobyteBuffer.remaining()bytes into byteBuffer from a given position in the file and returns the number of bytes read.intread(ByteBuffer byteBuffer)Reads up to byteBuffer.remaining() bytes into byteBuffer.
-
-
-
Method Detail
-
read
int read(ByteBuffer byteBuffer) throws IOException
Reads up to byteBuffer.remaining() bytes into byteBuffer. Callers should use byteBuffer.limit(..) to control the size of the desired read.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.
- Parameters:
byteBuffer- the ByteBuffer to receive the results of the read operation.- Returns:
- the number of bytes read, possibly zero, or -1 if reach end-of-stream
- Throws:
IOException- if there is some error performing the read
-
read
int read(long position, ByteBuffer byteBuffer) throws IOExceptionReads up tobyteBuffer.remaining()bytes into byteBuffer from a given position in the file and returns the number of bytes read. Callers should usebyteBuffer.limit(...)to control the size of the desired read andbyteBuffer.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 andbyteBuffer.limit()will be unchanged.In the case of an exception, the state of the buffer (the contents of the buffer, the
buf.position(), thebuf.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.
- Parameters:
position- position within filebyteBuffer- the ByteBuffer to receive the results of the read operation.- Returns:
- the number of bytes read, possibly zero, or -1 if reached end-of-stream
- Throws:
IOException- if there is some error performing the read
-
-