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
FieldsModifier and TypeFieldDescriptionprivate Cell[]protected CellComparatorNeeded 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadd(byte[] key, long offset, int dataSize) Adds a new entry in the root block index.protected longcalculateHeapSizeForBlockKeys(long heapSize) getRootBlockKey(int i) from 0 to- 1protected voidinitialize(int numEntries) booleanisEmpty()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.introotBlockContainingKey(byte[] key, int offset, int length, CellComparator comp) Finds the root-level index block containing the given key.intFinds 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:
calculateHeapSizeForBlockKeysin classHFileBlockIndex.BlockIndexReader
-
isEmpty
Description copied from class:HFileBlockIndex.BlockIndexReaderReturns true if the block index is empty.- Specified by:
isEmptyin 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.BlockIndexReaderReturn 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:
loadDataBlockWithScanInfoin 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.BlockIndexReaderAn 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:
midkeyin classHFileBlockIndex.BlockIndexReader- Returns:
- the first key of the middle block
- Throws:
IOException
-
initialize
- Specified by:
initializein classHFileBlockIndex.BlockIndexReader
-
add
Adds a new entry in the root block index. Only used when reading.- Specified by:
addin 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.BlockIndexReaderFinds the root-level index block containing the given key. Key to find the comparator to be used- Specified by:
rootBlockContainingKeyin 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.BlockIndexReaderFinds the root-level index block containing the given key. Key to find- Specified by:
rootBlockContainingKeyin classHFileBlockIndex.BlockIndexReader
-
toString
-