@PublicApi @NotThreadSafe public class FileInStream extends InputStream implements BoundedStream, PositionedReadable, alluxio.Seekable
read() methods to access this stream of bytes. In addition, one can seek
into a given offset of the stream to read.
This class wraps the block in stream for each of the blocks in the file and abstracts the
switching between streams. The backing streams can read from Alluxio space in the local machine,
remote machines, or the under storage system.
The internal bookkeeping works as follows:
1. updateStream() is a potentially expensive operation and is responsible for
creating new BlockInStreams and updating mBlockInStream. After calling this method,
mBlockInStream is ready to serve reads from the current mPosition.
2. mPosition can become out of sync with mBlockInStream when seek or skip is
called. When this happens, mBlockInStream is set to null and no effort is made to
sync between the two until updateStream() is called.
3. updateStream() is only called when followed by a read request. Thus, if a
mBlockInStream is created, it is guaranteed we read at least one byte from it.| Modifier | Constructor and Description |
|---|---|
protected |
FileInStream(alluxio.client.file.URIStatus status,
InStreamOptions options,
FileSystemContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
getPos() |
int |
positionedRead(long pos,
byte[] b,
int off,
int len)
Reads up to the specified number of bytes, from a given position within a file, and return the
number of bytes read.
|
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
long |
remaining() |
void |
seek(long pos) |
long |
skip(long n) |
available, mark, markSupported, resetprotected FileInStream(alluxio.client.file.URIStatus status,
InStreamOptions options,
FileSystemContext context)
throws IOException
IOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic long remaining()
remaining in interface BoundedStreampublic int positionedRead(long pos,
byte[] b,
int off,
int len)
throws IOException
PositionedReadablepositionedRead in interface PositionedReadablepos - position within fileb - destination bufferoff - offset in the bufferlen - number of bytes to readIOExceptionpublic long getPos()
getPos in interface alluxio.Positionedpublic void seek(long pos)
throws IOException
seek in interface alluxio.SeekableIOExceptionCopyright © 2024. All Rights Reserved.