@PublicApi @NotThreadSafe public class AlluxioFileInStream extends FileInStream
FileInStream
for data stored in Alluxio.
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 |
AlluxioFileInStream(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)
Moves the starting read position of the stream to the specified position which is relative to
the start of the stream.
|
long |
skip(long n) |
available, mark, markSupported, reset
protected AlluxioFileInStream(URIStatus status, InStreamOptions options, FileSystemContext context)
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 void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public long remaining()
public int positionedRead(long pos, byte[] b, int off, int len) throws IOException
PositionedReadable
pos
- position within fileb
- destination bufferoff
- offset in the bufferlen
- number of bytes to readIOException
public long getPos()
public void seek(long pos) throws IOException
Seekable
pos
- the position to seek to, it must be between 0 and the end of the stream - 1IOException
Copyright © 2023. All Rights Reserved.