Package alluxio.underfs
Class MultiRangeObjectInputStream
- java.lang.Object
-
- java.io.InputStream
-
- alluxio.underfs.MultiRangeObjectInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
@NotThreadSafe public abstract class MultiRangeObjectInputStream extends java.io.InputStream
A stream for reading data using range queries.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
mClosed
Has the stream been closed.protected long
mEndPos
Position the current stream was open till (exclusive).protected long
mPos
The current position of the stream.protected java.io.InputStream
mStream
The backing input stream.
-
Constructor Summary
Constructors Modifier Constructor Description protected
MultiRangeObjectInputStream(long multiRangeChunkSize)
Creates the input stream that will perform reads with a specified chunk size.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
protected abstract java.io.InputStream
createStream(long startPos, long endPos)
Opens a new stream reading a range.int
read()
int
read(byte[] b)
int
read(byte[] b, int offset, int length)
long
skip(long n)
-
-
-
Constructor Detail
-
MultiRangeObjectInputStream
protected MultiRangeObjectInputStream(long multiRangeChunkSize)
Creates the input stream that will perform reads with a specified chunk size. Reading in chunks allows us to read in smaller portions so that we don't need to read all the way to the end of a block.- Parameters:
multiRangeChunkSize
- the chunk size in bytes to read with
-
-
Method Detail
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int offset, int length) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
createStream
protected abstract java.io.InputStream createStream(long startPos, long endPos) throws java.io.IOException
Opens a new stream reading a range. When endPos > content length, the returned stream should read till the last valid byte of the input. The behaviour is undefined when (startPos < 0), (startPos >= content length), or (endPos <= 0).- Parameters:
startPos
- start position in bytes (inclusive)endPos
- end position in bytes (exclusive)- Returns:
- a new
InputStream
- Throws:
java.io.IOException
-
-