@InterfaceAudience.Public
@InterfaceStability.Evolving
public interface PositionedReadable
Seekable.getPos()
visible.Modifier and Type | Method and Description |
---|---|
default int |
maxReadSizeForVectorReads()
What is the largest size that we should group ranges together as?
|
default int |
minSeekForVectorReads()
What is the smallest reasonable seek?
|
int |
read(long position,
byte[] buffer,
int offset,
int length)
Read up to the specified number of bytes, from a given
position within a file, and return the number of bytes read.
|
void |
readFully(long position,
byte[] buffer)
Read number of bytes equal to the length of the buffer, from a given
position within a file.
|
void |
readFully(long position,
byte[] buffer,
int offset,
int length)
Read the specified number of bytes, from a given
position within a file.
|
default void |
readVectored(List<? extends org.apache.hadoop.fs.FileRange> ranges,
IntFunction<ByteBuffer> allocate)
Read fully a list of file ranges asynchronously from this file.
|
default void |
readVectored(List<? extends org.apache.hadoop.fs.FileRange> ranges,
IntFunction<ByteBuffer> allocate,
Consumer<ByteBuffer> release)
Extension of
readVectored(List, IntFunction) where a release(buffer)
operation may be invoked if problems surface during reads. |
int read(long position, byte[] buffer, int offset, int length) throws IOException
position
- position within filebuffer
- destination bufferoffset
- offset in the bufferlength
- number of bytes to readIOException
- IO problems.void readFully(long position, byte[] buffer, int offset, int length) throws IOException
position
- position within filebuffer
- destination bufferoffset
- offset in the bufferlength
- number of bytes to readIOException
- IO problems.EOFException
- the end of the data was reached before
the read operation completedvoid readFully(long position, byte[] buffer) throws IOException
position
- position within filebuffer
- destination bufferIOException
- IO problems.EOFException
- the end of the data was reached before
the read operation completeddefault int minSeekForVectorReads()
default int maxReadSizeForVectorReads()
default void readVectored(List<? extends org.apache.hadoop.fs.FileRange> ranges, IntFunction<ByteBuffer> allocate) throws IOException
The position returned by getPos() after readVectored() is undefined.
If a file is changed while the readVectored() operation is in progress, the output is undefined. Some ranges may have old data, some may have new and some may have both.
While a readVectored() operation is in progress, normal read api calls may block.
ranges
- the byte ranges to readallocate
- the function to allocate ByteBufferIOException
- any IOE.IllegalArgumentException
- if the any of ranges are invalid, or they overlap.default void readVectored(List<? extends org.apache.hadoop.fs.FileRange> ranges, IntFunction<ByteBuffer> allocate, Consumer<ByteBuffer> release) throws IOException
readVectored(List, IntFunction)
where a release(buffer)
operation may be invoked if problems surface during reads.
The release
operation is invoked after an IOException
to return the actively buffer to a pool before reporting a failure
in the future.
The default implementation calls readVectored(List, IntFunction)
.p
Implementations SHOULD override this method if they can release buffers as part of their error handling.
ranges
- the byte ranges to readallocate
- function to allocate ByteBufferrelease
- callable to release a ByteBuffer.IOException
- any IOE.IllegalArgumentException
- if any of ranges are invalid, or they overlap.NullPointerException
- null arguments.Copyright © 2025 Apache Software Foundation. All rights reserved.