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 Details

    • blockKeys

      private final List<byte[]> blockKeys
      First keys of the key range corresponding to each index entry.
    • blockOffsets

      private final List<Long> blockOffsets
      Block offset in backing stream.
    • onDiskDataSizes

      private final List<Integer> onDiskDataSizes
      On-disk data sizes of lower-level data or index blocks.
    • numSubEntriesAt

      private final List<Long> 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

      private int 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

  • Method Details

    • add

      public void add(byte[] firstKey, long blockOffset, int onDiskDataSize, long curTotalNumSubEntries)
      Adds a new entry to this block index chunk.
      Specified by:
      add in interface BlockIndexChunk
      Parameters:
      firstKey - the first key in the block pointed to by this entry
      blockOffset - the offset of the next-level block pointed to by this entry
      onDiskDataSize - the on-disk data of the block pointed to by this entry, including header size
      curTotalNumSubEntries - 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

      public void add(byte[] firstKey, long blockOffset, int onDiskDataSize)
      The same as add(byte[], long, int, long) but does not take the key/value into account. Used for single-level indexes.
      Specified by:
      add in interface BlockIndexChunk
      See Also:
    • clear

      public void clear()
      Specified by:
      clear in interface BlockIndexChunk
    • getEntryBySubEntry

      public 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.

      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 interface BlockIndexChunk
      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

      public byte[] getMidKeyMetadata() throws IOException
      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 interface BlockIndexChunk
      Returns:
      a few serialized fields for finding the mid-key
      Throws:
      IOException - if could not create metadata for computing mid-key
    • getNonRootSize

      public int getNonRootSize()
      Returns the size of this chunk if stored in the non-root index block format
      Specified by:
      getNonRootSize in interface BlockIndexChunk
    • getCurTotalNonRootEntrySize

      Specified by:
      getCurTotalNonRootEntrySize in interface BlockIndexChunk
    • getBlockKeys

      public List<byte[]> getBlockKeys()
      Specified by:
      getBlockKeys in interface BlockIndexChunk
    • getSecondaryIndexOffsetMarks

      Specified by:
      getSecondaryIndexOffsetMarks in interface BlockIndexChunk
    • getRootSize

      public int getRootSize()
      Returns the size of this chunk if stored in the root index block format
      Specified by:
      getRootSize in interface BlockIndexChunk
    • getNumEntries

      public int getNumEntries()
      Returns the number of entries in this block index chunk
      Specified by:
      getNumEntries in interface BlockIndexChunk
    • getBlockKey

      public byte[] getBlockKey(int i)
      Specified by:
      getBlockKey in interface BlockIndexChunk
    • getBlockOffset

      public long getBlockOffset(int i)
      Specified by:
      getBlockOffset in interface BlockIndexChunk
    • getOnDiskDataSize

      public int getOnDiskDataSize(int i)
      Specified by:
      getOnDiskDataSize in interface BlockIndexChunk
    • getCumulativeNumKV

      public long getCumulativeNumKV(int i)