|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.io.hfile.HFileBlockIndex.BlockIndexReader
public static class HFileBlockIndex.BlockIndexReader
The reader will always hold the root level index in the memory. Index blocks at all other levels will be cached in the LRU cache in practice, although this API does not enforce that. All non-root (leaf and intermediate) index blocks contain what we call a "secondary index": an array of offsets to the entries within the block. This allows us to do binary search for the entry corresponding to the given key without having to deserialize the block.
Constructor Summary | |
---|---|
HFileBlockIndex.BlockIndexReader(org.apache.hadoop.io.RawComparator<byte[]> c,
int treeLevel)
|
|
HFileBlockIndex.BlockIndexReader(org.apache.hadoop.io.RawComparator<byte[]> c,
int treeLevel,
HFile.CachingBlockReader cachingBlockReader)
|
Method Summary | |
---|---|
void |
ensureNonEmpty()
Verifies that the block index is non-empty and throws an IllegalStateException otherwise. |
int |
getRootBlockCount()
|
int |
getRootBlockDataSize(int i)
|
byte[] |
getRootBlockKey(int i)
|
long |
getRootBlockOffset(int i)
|
long |
heapSize()
|
boolean |
isEmpty()
|
BlockWithScanInfo |
loadDataBlockWithScanInfo(byte[] key,
int keyOffset,
int keyLength,
HFileBlock currentBlock,
boolean cacheBlocks,
boolean pread,
boolean isCompaction)
Return the BlockWithScanInfo which contains the DataBlock with other scan info such as nextIndexedKey. |
byte[] |
midkey()
An approximation to the HFile 's mid-key. |
void |
readMultiLevelIndexRoot(HFileBlock blk,
int numEntries)
Read the root-level metadata of a multi-level block index. |
void |
readRootIndex(java.io.DataInput in,
int numEntries)
Read in the root-level index from the given input stream. |
java.io.DataInputStream |
readRootIndex(HFileBlock blk,
int numEntries)
Read in the root-level index from the given input stream. |
int |
rootBlockContainingKey(byte[] key,
int offset,
int length)
Finds the root-level index block containing the given key. |
HFileBlock |
seekToDataBlock(byte[] key,
int keyOffset,
int keyLength,
HFileBlock currentBlock,
boolean cacheBlocks,
boolean pread,
boolean isCompaction)
Return the data block which contains this key. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HFileBlockIndex.BlockIndexReader(org.apache.hadoop.io.RawComparator<byte[]> c, int treeLevel, HFile.CachingBlockReader cachingBlockReader)
public HFileBlockIndex.BlockIndexReader(org.apache.hadoop.io.RawComparator<byte[]> c, int treeLevel)
Method Detail |
---|
public boolean isEmpty()
public void ensureNonEmpty()
IllegalStateException
otherwise.
public HFileBlock seekToDataBlock(byte[] key, int keyOffset, int keyLength, HFileBlock currentBlock, boolean cacheBlocks, boolean pread, boolean isCompaction) throws java.io.IOException
key
- the key we are looking forkeyOffset
- the offset of the key in its byte arraykeyLength
- the length of the keycurrentBlock
- the current block, to avoid re-reading the same
block
java.io.IOException
public BlockWithScanInfo loadDataBlockWithScanInfo(byte[] key, int keyOffset, int keyLength, HFileBlock currentBlock, boolean cacheBlocks, boolean pread, boolean isCompaction) throws java.io.IOException
key
- the key we are looking forkeyOffset
- the offset of the key in its byte arraykeyLength
- the length of the keycurrentBlock
- the current block, to avoid re-reading the same
blockcacheBlocks
- pread
- isCompaction
-
java.io.IOException
public byte[] midkey() throws java.io.IOException
HFile
'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.
java.io.IOException
public byte[] getRootBlockKey(int i)
i
- from 0 to - 1
public long getRootBlockOffset(int i)
i
- from 0 to - 1
public int getRootBlockDataSize(int i)
i
- zero-based index of a root-level block
public int getRootBlockCount()
public int rootBlockContainingKey(byte[] key, int offset, int length)
key
- Key to find
key
(between 0 and the
number of blocks - 1) or -1 if this file does not contain the
request.public void readRootIndex(java.io.DataInput in, int numEntries) throws java.io.IOException
HFileBlockIndex.BlockIndexWriter.writeIndexBlocks(FSDataOutputStream)
at the
offset that function returned.
in
- the buffered input stream or wrapped byte input streamnumEntries
- the number of root-level index entries
java.io.IOException
public java.io.DataInputStream readRootIndex(HFileBlock blk, int numEntries) throws java.io.IOException
HFileBlockIndex.BlockIndexWriter.writeIndexBlocks(FSDataOutputStream)
at the
offset that function returned.
blk
- the HFile blocknumEntries
- the number of root-level index entries
java.io.IOException
public void readMultiLevelIndexRoot(HFileBlock blk, int numEntries) throws java.io.IOException
readRootIndex(DataInput, int)
, but also reads metadata
necessary to compute the mid-key in a multi-level index.
blk
- the HFile blocknumEntries
- the number of root-level index entries
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public long heapSize()
heapSize
in interface HeapSize
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |