Package org.apache.hadoop.hbase.io.hfile
Class HFileBlockIndex.CellBasedKeyBlockIndexReader
java.lang.Object
org.apache.hadoop.hbase.io.hfile.HFileBlockIndex.BlockIndexReader
org.apache.hadoop.hbase.io.hfile.HFileBlockIndex.CellBasedKeyBlockIndexReader
- All Implemented Interfaces:
HeapSize
- Direct Known Subclasses:
HFileBlockIndex.CellBasedKeyBlockIndexReaderV2
- Enclosing class:
- HFileBlockIndex
An implementation of the BlockIndexReader that deals with block keys which are the key part of
a cell like the Data block index or the ROW_COL bloom blocks This needs a comparator to work
with the Cells
-
Field Summary
Modifier and TypeFieldDescriptionprivate Cell[]
protected CellComparator
Needed doing lookup on blocks.private AtomicReference<Cell>
Pre-computed mid-keyFields inherited from class org.apache.hadoop.hbase.io.hfile.HFileBlockIndex.BlockIndexReader
blockDataSizes, blockOffsets, midKeyEntry, midLeafBlockOffset, midLeafBlockOnDiskSize, rootCount, searchTreeLevel
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
add
(byte[] key, long offset, int dataSize) Adds a new entry in the root block index.protected long
calculateHeapSizeForBlockKeys
(long heapSize) getRootBlockKey
(int i) from 0 to- 1
protected void
initialize
(int numEntries) boolean
isEmpty()
Returns true if the block index is empty.loadDataBlockWithScanInfo
(Cell key, HFileBlock currentBlock, boolean cacheBlocks, boolean pread, boolean isCompaction, DataBlockEncoding expectedDataBlockEncoding, HFile.CachingBlockReader cachingBlockReader) Return the BlockWithScanInfo, a data structure which contains the Data HFileBlock with other scan info such as the key that starts the next HFileBlock.midkey
(HFile.CachingBlockReader cachingBlockReader) An approximation to theHFile
's mid-key.int
rootBlockContainingKey
(byte[] key, int offset, int length, CellComparator comp) Finds the root-level index block containing the given key.int
Finds the root-level index block containing the given key.toString()
Methods inherited from class org.apache.hadoop.hbase.io.hfile.HFileBlockIndex.BlockIndexReader
binarySearchNonRootIndex, ensureNonEmpty, getNonRootIndexedKey, getRootBlockCount, getRootBlockDataSize, getRootBlockOffset, heapSize, locateNonRootIndexEntry, readMultiLevelIndexRoot, readRootIndex, readRootIndex, rootBlockContainingKey, seekToDataBlock
-
Field Details
-
blockKeys
-
midKey
Pre-computed mid-key -
comparator
Needed doing lookup on blocks.
-
-
Constructor Details
-
CellBasedKeyBlockIndexReader
-
-
Method Details
-
calculateHeapSizeForBlockKeys
- Specified by:
calculateHeapSizeForBlockKeys
in classHFileBlockIndex.BlockIndexReader
-
isEmpty
Description copied from class:HFileBlockIndex.BlockIndexReader
Returns true if the block index is empty.- Specified by:
isEmpty
in classHFileBlockIndex.BlockIndexReader
-
getRootBlockKey
from 0 to- 1
-
loadDataBlockWithScanInfo
public BlockWithScanInfo loadDataBlockWithScanInfo(Cell key, HFileBlock currentBlock, boolean cacheBlocks, boolean pread, boolean isCompaction, DataBlockEncoding expectedDataBlockEncoding, HFile.CachingBlockReader cachingBlockReader) throws IOException Description copied from class:HFileBlockIndex.BlockIndexReader
Return the BlockWithScanInfo, a data structure which contains the Data HFileBlock with other scan info such as the key that starts the next HFileBlock. This function will only be called when the HFile version is larger than 1.- Specified by:
loadDataBlockWithScanInfo
in classHFileBlockIndex.BlockIndexReader
- Parameters:
key
- the key we are looking forcurrentBlock
- the current block, to avoid re-reading the same blockexpectedDataBlockEncoding
- the data block encoding the caller is expecting the data block to be in, or null to not perform this check and return the block irrespective of the encoding.- Returns:
- the BlockWithScanInfo which contains the DataBlock with other scan info such as nextIndexedKey.
- Throws:
IOException
-
midkey
Description copied from class:HFileBlockIndex.BlockIndexReader
An approximation to theHFile
's mid-key. Operates on block boundaries, and does not go inside blocks. In other words, returns the first key of the middle block of the file.- Specified by:
midkey
in classHFileBlockIndex.BlockIndexReader
- Returns:
- the first key of the middle block
- Throws:
IOException
-
initialize
- Specified by:
initialize
in classHFileBlockIndex.BlockIndexReader
-
add
Adds a new entry in the root block index. Only used when reading.- Specified by:
add
in classHFileBlockIndex.BlockIndexReader
- Parameters:
key
- Last key in the blockoffset
- file offset where the block is storeddataSize
- the uncompressed data size
-
rootBlockContainingKey
Description copied from class:HFileBlockIndex.BlockIndexReader
Finds the root-level index block containing the given key. Key to find the comparator to be used- Specified by:
rootBlockContainingKey
in classHFileBlockIndex.BlockIndexReader
- Returns:
- Offset of block containing
key
(between 0 and the number of blocks - 1) or -1 if this file does not contain the request.
-
rootBlockContainingKey
Description copied from class:HFileBlockIndex.BlockIndexReader
Finds the root-level index block containing the given key. Key to find- Specified by:
rootBlockContainingKey
in classHFileBlockIndex.BlockIndexReader
-
toString
-