Package org.apache.hadoop.hbase.io.hfile
Class HFileBlockIndex.BlockIndexChunkImpl
java.lang.Object
org.apache.hadoop.hbase.io.hfile.HFileBlockIndex.BlockIndexChunkImpl
- All Implemented Interfaces:
BlockIndexChunk
- Enclosing class:
- HFileBlockIndex
A single chunk of the block index in the process of writing. The data in this chunk can become
a leaf-level, intermediate-level, or root index block.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List<byte[]>
First keys of the key range corresponding to each index entry.Block offset in backing stream.private int
The offset of the next entry to be added, relative to the end of the "secondary index" in the "non-root" format representation of this index chunk.private int
The accumulated size of this chunk if stored in the root index format.The cumulative number of sub-entries, i.e.On-disk data sizes of lower-level data or index blocks.The "secondary index" used for binary search over variable-length records in a "non-root" format block. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(byte[] firstKey, long blockOffset, int onDiskDataSize) The same asadd(byte[], long, int, long)
but does not take the key/value into account.void
add
(byte[] firstKey, long blockOffset, int onDiskDataSize, long curTotalNumSubEntries) Adds a new entry to this block index chunk.void
clear()
byte[]
getBlockKey
(int i) List<byte[]>
long
getBlockOffset
(int i) long
getCumulativeNumKV
(int i) int
int
getEntryBySubEntry
(long k) Finds the entry corresponding to the deeper-level index block containing the given deeper-level entry (a "sub-entry"), assuming a global 0-based ordering of sub-entries.byte[]
Used when writing the root block index of a multi-level block index.int
Returns the size of this chunk if stored in the non-root index block formatint
Returns the number of entries in this block index chunkint
getOnDiskDataSize
(int i) int
Returns the size of this chunk if stored in the root index block format
-
Field Details
-
blockKeys
First keys of the key range corresponding to each index entry. -
blockOffsets
Block offset in backing stream. -
onDiskDataSizes
On-disk data sizes of lower-level data or index blocks. -
numSubEntriesAt
The cumulative number of sub-entries, i.e. entries on deeper-level block index entries. numSubEntriesAt[i] is the number of sub-entries in the blocks corresponding to this chunk's entries #0 through #i inclusively. -
curTotalNonRootEntrySize
The offset of the next entry to be added, relative to the end of the "secondary index" in the "non-root" format representation of this index chunk. This is the next value to be added to the secondary index. -
curTotalRootSize
The accumulated size of this chunk if stored in the root index format. -
secondaryIndexOffsetMarks
The "secondary index" used for binary search over variable-length records in a "non-root" format block. These offsets are relative to the end of this secondary index.
-
-
Constructor Details
-
BlockIndexChunkImpl
-
-
Method Details
-
add
Adds a new entry to this block index chunk.- Specified by:
add
in interfaceBlockIndexChunk
- Parameters:
firstKey
- the first key in the block pointed to by this entryblockOffset
- the offset of the next-level block pointed to by this entryonDiskDataSize
- the on-disk data of the block pointed to by this entry, including header sizecurTotalNumSubEntries
- if this chunk is the root index chunk under construction, this specifies the current total number of sub-entries in all leaf-level chunks, including the one corresponding to the second-level entry being added.
-
add
The same asadd(byte[], long, int, long)
but does not take the key/value into account. Used for single-level indexes.- Specified by:
add
in interfaceBlockIndexChunk
- See Also:
-
clear
- Specified by:
clear
in interfaceBlockIndexChunk
-
getEntryBySubEntry
Finds the entry corresponding to the deeper-level index block containing the given deeper-level entry (a "sub-entry"), assuming a global 0-based ordering of sub-entries.Implementation note. We are looking for i such that numSubEntriesAt[i - 1] <= k < numSubEntriesAt[i], because a deeper-level block #i (0-based) contains sub-entries # numSubEntriesAt[i - 1]'th through numSubEntriesAt[i] - 1, assuming a global 0-based ordering of sub-entries. i is by definition the insertion point of k in numSubEntriesAt.
- Specified by:
getEntryBySubEntry
in interfaceBlockIndexChunk
- Parameters:
k
- sub-entry index, from 0 to the total number sub-entries - 1- Returns:
- the 0-based index of the entry corresponding to the given sub-entry
-
getMidKeyMetadata
Used when writing the root block index of a multi-level block index. Serializes additional information allowing to efficiently identify the mid-key.- Specified by:
getMidKeyMetadata
in interfaceBlockIndexChunk
- Returns:
- a few serialized fields for finding the mid-key
- Throws:
IOException
- if could not create metadata for computing mid-key
-
getNonRootSize
Returns the size of this chunk if stored in the non-root index block format- Specified by:
getNonRootSize
in interfaceBlockIndexChunk
-
getCurTotalNonRootEntrySize
- Specified by:
getCurTotalNonRootEntrySize
in interfaceBlockIndexChunk
-
getBlockKeys
- Specified by:
getBlockKeys
in interfaceBlockIndexChunk
-
getSecondaryIndexOffsetMarks
- Specified by:
getSecondaryIndexOffsetMarks
in interfaceBlockIndexChunk
-
getRootSize
Returns the size of this chunk if stored in the root index block format- Specified by:
getRootSize
in interfaceBlockIndexChunk
-
getNumEntries
Returns the number of entries in this block index chunk- Specified by:
getNumEntries
in interfaceBlockIndexChunk
-
getBlockKey
- Specified by:
getBlockKey
in interfaceBlockIndexChunk
-
getBlockOffset
- Specified by:
getBlockOffset
in interfaceBlockIndexChunk
-
getOnDiskDataSize
- Specified by:
getOnDiskDataSize
in interfaceBlockIndexChunk
-
getCumulativeNumKV
-