Package org.apache.flink.state.forst.fs
Class ByteBufferReadableFSDataInputStream
java.lang.Object
java.io.InputStream
org.apache.flink.core.fs.FSDataInputStream
org.apache.flink.state.forst.fs.ByteBufferReadableFSDataInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ByteBufferReadableFSDataInputStream
extends org.apache.flink.core.fs.FSDataInputStream
A
FSDataInputStream delegates requests to other one and supports reading data with ByteBuffer.
All methods in this class maybe used by ForSt, please start a discussion firstly if it has to be modified.
-
Constructor Summary
ConstructorsConstructorDescriptionByteBufferReadableFSDataInputStream(Callable<org.apache.flink.core.fs.FSDataInputStream> inputStreamBuilder, int inputStreamCapacity, long totalFileSize) -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()longgetPos()voidmark(int readlimit) booleanintread()intread(byte[] b) intread(byte[] b, int off, int len) intreadFully(long position, ByteBuffer bb) Reads up toByteBuffer#remainingbytes of data from the specific position of the input stream into a ByteBuffer.intreadFully(ByteBuffer bb) Reads up toByteBuffer#remainingbytes of data from the input stream into a ByteBuffer.voidreset()voidseek(long desired) longskip(long n) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
Constructor Details
-
ByteBufferReadableFSDataInputStream
public ByteBufferReadableFSDataInputStream(Callable<org.apache.flink.core.fs.FSDataInputStream> inputStreamBuilder, int inputStreamCapacity, long totalFileSize) throws IOException - Throws:
IOException
-
-
Method Details
-
readFully
Reads up toByteBuffer#remainingbytes of data from the input stream into a ByteBuffer. Not Thread-safe yet since the interface of sequential read of ForSt only be accessed by one thread at a time. TODO: Rename all methods about 'readFully' to 'read' when next version of ForSt is ready.- Parameters:
bb- the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer.
- Throws:
IOException- If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.NullPointerException- Ifbbisnull.
-
readFully
Reads up toByteBuffer#remainingbytes of data from the specific position of the input stream into a ByteBuffer. Thread-safe since the interface of random read of ForSt may be concurrently accessed by multiple threads. TODO: Support to split this method to other class.- Parameters:
position- the start offset in input stream at which the data is read.bb- the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer.
- Throws:
IOException- If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.NullPointerException- Ifbbisnull.Exception
-
seek
- Specified by:
seekin classorg.apache.flink.core.fs.FSDataInputStream- Throws:
IOException
-
getPos
- Specified by:
getPosin classorg.apache.flink.core.fs.FSDataInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-