@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(java.nio.ByteBuffer byteBuffer,
int off,
int len)
Reads up to len bytes of data from the input stream into the byte buffer.
|
long |
remaining() |
void |
seek(long pos) |
long |
skip(long n) |
read, read, readprotected AlluxioFileInStream(URIStatus status, InStreamOptions options, FileSystemContext context)
public int read()
throws java.io.IOException
read in class FileInStreamjava.io.IOExceptionpublic int read(java.nio.ByteBuffer byteBuffer,
int off,
int len)
throws java.io.IOException
FileInStreamread in class FileInStreambyteBuffer - the buffer into which the data is readoff - the start offset in the buffer at which the data is writtenlen - the maximum number of bytes to readjava.io.IOExceptionpublic long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic long remaining()
public int positionedRead(long pos,
byte[] b,
int off,
int len)
throws java.io.IOException
PositionedReadablepos - position within fileb - destination bufferoff - offset in the bufferlen - number of bytes to readjava.io.IOExceptionpublic long getPos()
public void seek(long pos)
throws java.io.IOException
java.io.IOExceptionCopyright © 2022. All Rights Reserved.