org.apache.hadoop.fs
Interface ByteBufferReadable
- All Known Implementing Classes:
- CryptoFSDataInputStream, FSDataInputStream
public interface ByteBufferReadable
Implementers of this interface provide a read API that writes to a
ByteBuffer, not a byte[].
Method Summary |
int |
read(ByteBuffer buf)
Reads up to buf.remaining() bytes into buf. |
read
int read(ByteBuffer buf)
throws IOException
- Reads up to buf.remaining() bytes into buf. Callers should use
buf.limit(..) to control the size of the desired read.
After a successful call, buf.position() and buf.limit() should be
unchanged, and therefore any data can be immediately read from buf.
buf.mark() may be cleared or updated.
In the case of an exception, the values of buf.position() and buf.limit()
are undefined, and callers should be prepared to recover from this
eventuality.
Many implementations will throw
UnsupportedOperationException
, so
callers that are not confident in support for this method from the
underlying filesystem should be prepared to handle that exception.
Implementations should treat 0-length requests as legitimate, and must not
signal an error upon their receipt.
- Parameters:
buf
- the ByteBuffer to receive the results of the read operation. Up to
buf.limit() - buf.position() bytes may be read.
- Returns:
- the number of bytes available to read from buf
- Throws:
IOException
- if there is some error performing the read
Copyright © 2014 Apache Software Foundation. All Rights Reserved.