Class VectorIoBridge
- java.lang.Object
-
- org.apache.parquet.hadoop.util.wrapped.io.VectorIoBridge
-
public final class VectorIoBridge extends Object
Vector IO bridge.This loads the
PositionedReadablemethod:void readVectored(List[?extends FileRange] ranges, IntFunction[ByteBuffer] allocate) throws IOExceptionIt is made slightly easier because of type erasure; the signature of the function is actuallyVoid.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanavailable()Is the bridge available?static VectorIoBridgeavailableInstance()Get the instance verifying that the API is available.static booleanbridgeAvailable()Is the bridge available for use?longgetBlocksRead()How many blocks were read?longgetBytesRead()How many bytes of data have been read.longgetVectorReads()How 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, 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<ParquetFileRange> ranges, ByteBufferAllocator allocator)Read fully a list of file ranges asynchronously from this file.StringtoString()
-
-
-
Method Detail
-
readVectoredAvailable
public boolean readVectoredAvailable(org.apache.hadoop.fs.FSDataInputStream stream, 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<ParquetFileRange> ranges, ByteBufferAllocator allocator) throws IOExceptionRead 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
-
hasCapability
public boolean hasCapability(org.apache.hadoop.fs.FSDataInputStream stream, String capability)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
public static VectorIoBridge 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
public static VectorIoBridge availableInstance()
Get the instance verifying that the API is available.- Returns:
- an available instance, always
- Throws:
UnsupportedOperationException- if it is not.
-
-