public interface RangeReadable
extends java.io.Closeable
RangeReadable
is an interface that allows for implementations of InputFile
streams to perform positional, range-based reads, which are more efficient than unbounded reads
in many cloud provider object stores.
Thread safety is not a requirement of the interface and is left to the implementation.
If the implementation is also a SeekableInputStream
, the position of the stream is not
required to be updated based on the positional reads performed by this interface. Usage of SeekableInputStream
should always seek to the appropriate position for InputStream
based reads.
Modifier and Type | Method and Description |
---|---|
default void |
readFully(long position,
byte[] buffer)
Fill the entire buffer with the contents of the input source starting at
position . |
void |
readFully(long position,
byte[] buffer,
int offset,
int length)
Fill the provided buffer with the contents of the input source starting at
position for
the given offset and length . |
default int |
readTail(byte[] buffer)
Read the full size of the buffer from the end of the file.
|
int |
readTail(byte[] buffer,
int offset,
int length)
Read the last
length bytes from the file. |
void readFully(long position, byte[] buffer, int offset, int length) throws java.io.IOException
position
for
the given offset
and length
.position
- start position of the readbuffer
- target buffer to copy dataoffset
- offset in the buffer to copy the datalength
- size of the readjava.io.IOException
default void readFully(long position, byte[] buffer) throws java.io.IOException
position
.position
- start position of the readbuffer
- target buffer to copy datajava.io.IOException
int readTail(byte[] buffer, int offset, int length) throws java.io.IOException
length
bytes from the file.buffer
- the buffer to write data intooffset
- the offset in the buffer to start writinglength
- the number of bytes from the end of the object to readjava.io.IOException
- if an error occurs while readingdefault int readTail(byte[] buffer) throws java.io.IOException
buffer
- the buffer to write data intojava.io.IOException
- if an error occurs while reading