public final class CompressedBlockReader extends Object implements Closeable
getRange(long, int). The ByteBuffer provided by this method may or may not
be valid after additional calls to getRange(long, int) or calls to seekBlock(int).
For fixed width values which are aligned with the block size, callers may also use the method
getDecompressedDataBuffer() to have direct access to the current uncompressed block, and use the methods
loadBlock(long) to load the correct block and translate a virtual offset into the relative offset, or
seekBlock(int) to change which block is currently loaded.
getRange(long, int) uses these same mechanisms internally to supply data.for writer| Modifier and Type | Field and Description |
|---|---|
static byte |
VERSION |
| Constructor and Description |
|---|
CompressedBlockReader(CompressionStrategy compressionStrategy,
int numBlocks,
int blockSize,
IntBuffer endOffsetsBuffer,
ByteBuffer compressedDataBuffer,
ByteOrder byteOrder) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static Supplier<CompressedBlockReader> |
fromByteBuffer(ByteBuffer buffer,
ByteOrder byteOrder) |
int |
getCurrentBlockNumber()
Get current block number of data loaded in
decompressedDataBuffer |
ByteBuffer |
getDecompressedDataBuffer()
Current decompressed data buffer of the data located in
currentBlockNumber |
ByteBuffer |
getRange(long startOffset,
int size)
Get
ByteBuffer containing data from starting offset of contiguous virtual address range of the specified
size. |
long |
getSize()
Get size in bytes of virtual contiguous buffer
|
int |
loadBlock(long startOffset)
Load the block for the specified virtual offset, returning the relative offset into
decompressedDataBuffer
of the currentBlockNumber. |
void |
seekBlock(int block)
Swap the current data in
decompressedDataBuffer to the specified block |
public static final byte VERSION
public CompressedBlockReader(CompressionStrategy compressionStrategy, int numBlocks, int blockSize, IntBuffer endOffsetsBuffer, ByteBuffer compressedDataBuffer, ByteOrder byteOrder)
public static Supplier<CompressedBlockReader> fromByteBuffer(ByteBuffer buffer, ByteOrder byteOrder)
public long getSize()
public int getCurrentBlockNumber()
decompressedDataBufferpublic ByteBuffer getDecompressedDataBuffer()
currentBlockNumberpublic ByteBuffer getRange(long startOffset, int size)
ByteBuffer containing data from starting offset of contiguous virtual address range of the specified
size. If this data spans more than a single block, it will be copied on heap, but if not, will be a view into
decompressedDataBuffer. The data returned by this method is not guaranteed to still be readable after
another call to getRange(long, int) or a call to seekBlock(int).public int loadBlock(long startOffset)
decompressedDataBuffer
of the currentBlockNumber.public void seekBlock(int block)
decompressedDataBuffer to the specified blockpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.