Class ByteBufferReadableClosingFSDataInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.flink.core.fs.FSDataInputStream
-
- org.apache.flink.core.fs.FSDataInputStreamWrapper
-
- org.apache.flink.core.fs.ClosingFSDataInputStream
-
- org.apache.flink.core.fs.ByteBufferReadableClosingFSDataInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteBufferReadable
,WrappingProxyCloseable<FSDataInputStream>
,WrappingProxy<FSDataInputStream>
@Internal public class ByteBufferReadableClosingFSDataInputStream extends ClosingFSDataInputStream implements ByteBufferReadable
AClosingFSDataInputStream
which isByteBufferReadable
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ByteBufferReadableClosingFSDataInputStream(FSDataInputStream delegate, SafetyNetCloseableRegistry registry, String debugInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
read(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.int
read(ByteBuffer byteBuffer)
Reads up to byteBuffer.remaining() bytes into byteBuffer.-
Methods inherited from class org.apache.flink.core.fs.ClosingFSDataInputStream
close, equals, hashCode, isClosed, toString, wrapSafe, wrapSafe
-
Methods inherited from class org.apache.flink.core.fs.FSDataInputStreamWrapper
available, getPos, getWrappedDelegate, mark, markSupported, read, read, read, reset, seek, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.flink.util.WrappingProxy
getWrappedDelegate
-
-
-
-
Constructor Detail
-
ByteBufferReadableClosingFSDataInputStream
protected ByteBufferReadableClosingFSDataInputStream(FSDataInputStream delegate, SafetyNetCloseableRegistry registry, String debugInfo) throws IOException
- Throws:
IOException
-
-
Method Detail
-
read
public int read(ByteBuffer byteBuffer) throws IOException
Description copied from interface:ByteBufferReadable
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.
- Specified by:
read
in interfaceByteBufferReadable
- 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
public int read(long position, ByteBuffer byteBuffer) throws IOException
Description copied from interface:ByteBufferReadable
Reads 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.
- Specified by:
read
in interfaceByteBufferReadable
- 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
-
-