Class VectorIoBridge
java.lang.Object
org.apache.parquet.hadoop.util.wrapped.io.VectorIoBridge
Vector IO bridge.
This loads the PositionedReadable method:
void readVectored(List[?extends FileRange] ranges,
IntFunction[ByteBuffer] allocate) throws IOException
It is made slightly easier because of type erasure; the signature of the
function is actually Void.class method(List.class, IntFunction.class).
There are some counters to aid in testing; the toString() method
will print them and the loaded method, for use in tests and debug logs.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanIs the bridge available?static VectorIoBridgeGet the instance verifying that the API is available.static booleanIs the bridge available for use?longHow many blocks were read?longHow many bytes of data have been read.longHow many vector read calls have been made?booleanhasCapability(org.apache.hadoop.fs.FSDataInputStream stream, String capability) Does a stream implement StreamCapability and, if so, is the capability available.static VectorIoBridgeinstance()Get the singleton instance.booleanreadVectoredAvailable(org.apache.hadoop.fs.FSDataInputStream stream, org.apache.parquet.bytes.ByteBufferAllocator allocator) Is the vectored IO API available for the given stream and allocator in this Hadoop runtime?voidreadVectoredRanges(org.apache.hadoop.fs.FSDataInputStream stream, List<org.apache.parquet.io.ParquetFileRange> ranges, org.apache.parquet.bytes.ByteBufferAllocator allocator) Read fully a list of file ranges asynchronously from this file.toString()
-
Method Details
-
readVectoredAvailable
public boolean readVectoredAvailable(org.apache.hadoop.fs.FSDataInputStream stream, org.apache.parquet.bytes.ByteBufferAllocator allocator) Is the vectored IO API available for the given stream and allocator in this Hadoop runtime?- Parameters:
stream- input stream to query.allocator- allocator to be used.- Returns:
- true if the stream declares the capability is available.
-
available
public boolean available()Is the bridge available?- Returns:
- true if readVectored() is available.
-
readVectoredRanges
public void readVectoredRanges(org.apache.hadoop.fs.FSDataInputStream stream, List<org.apache.parquet.io.ParquetFileRange> ranges, org.apache.parquet.bytes.ByteBufferAllocator allocator) throws IOException Read fully a list of file ranges asynchronously from this file. The default iterates through the ranges to read each synchronously, but the intent is that FSDataInputStream subclasses can make more efficient readers. TheParquetFileRangeparameters all have their data read futures set to the range reads of the associated operations; callers must await these to complete.As a result of the call, each range will have FileRange.setData(CompletableFuture) called with a future that when complete will have a ByteBuffer with the data from the file's range.
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.
- Parameters:
stream- stream from where the data has to be read.ranges- parquet file ranges.allocator- buffer allocator.- Throws:
UnsupportedOperationException- if the API is not available.EOFException- if a range is past the known end of the file.IOException- any IO problem initiating the read operations.IllegalArgumentException- if there are overlapping ranges or a range element is invalid
-
toString
-
hasCapability
Does a stream implement StreamCapability and, if so, is the capability available. The call will return false if- The method is not found
- The method is found but throws an exception when invoked
- The method is found, invoked and returns false
- Parameters:
stream- input stream to query.capability- the capability to look for.- Returns:
- true if the stream declares the capability is available.
-
getVectorReads
public long getVectorReads()How many vector read calls have been made?- Returns:
- the count of vector reads.
-
getBlocksRead
public long getBlocksRead()How many blocks were read?- Returns:
- the count of blocks read.
-
getBytesRead
public long getBytesRead()How many bytes of data have been read.- Returns:
- the count of bytes read.
-
instance
Get the singleton instance.- Returns:
- instance.
-
bridgeAvailable
public static boolean bridgeAvailable()Is the bridge available for use?- Returns:
- true if the vector IO API is available.
-
availableInstance
Get the instance verifying that the API is available.- Returns:
- an available instance, always
- Throws:
UnsupportedOperationException- if it is not.
-