@Experimental public class ByteBufferReadableFSDataInputStream extends FSDataInputStream
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 and Description |
---|
ByteBufferReadableFSDataInputStream(Callable<FSDataInputStream> inputStreamBuilder,
int inputStreamCapacity,
long totalFileSize) |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
long |
getPos()
Gets the current position in the input stream.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
int |
readFully(ByteBuffer bb)
Reads up to
ByteBuffer#remaining bytes of data from the input stream into a
ByteBuffer. |
int |
readFully(long position,
ByteBuffer bb)
Reads up to
ByteBuffer#remaining bytes of data from the specific position of the
input stream into a ByteBuffer. |
void |
reset() |
void |
seek(long desired)
Seek to the given offset from the start of the file.
|
long |
skip(long n) |
public ByteBufferReadableFSDataInputStream(Callable<FSDataInputStream> inputStreamBuilder, int inputStreamCapacity, long totalFileSize) throws IOException
IOException
public int readFully(ByteBuffer bb) throws IOException
ByteBuffer#remaining
bytes 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.bb
- the buffer into which the data is read.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
- If bb
is null
.public int readFully(long position, ByteBuffer bb) throws Exception
ByteBuffer#remaining
bytes 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.position
- the start offset in input stream at which the data is read.bb
- the buffer into which the data is read.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
- If bb
is null
.Exception
public void seek(long desired) throws IOException
FSDataInputStream
seek
in class FSDataInputStream
desired
- the desired offsetIOException
- Thrown if an error occurred while seeking inside the input stream.public long getPos() throws IOException
FSDataInputStream
getPos
in class FSDataInputStream
IOException
- Thrown if an I/O error occurred in the underlying stream implementation
while accessing the stream's position.public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
public boolean markSupported()
markSupported
in class InputStream
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.