Class KeyBlockEntry


public class KeyBlockEntry extends FixSizeEntry
Represents an entry with exactly one key.

Every entry contains: block index, block offset, id, eol, version.

Block index and offset reference a region in the var size block where the key data is stored.

Var size block can be either multi block or single block.

Multi block would reference a key, which size is greater than one block. A single (or multi-entry) block would reference a block that contain one complete or several keys.

  • Constructor Details

  • Method Details

    • getRecordLengths

      public RecordLengths getRecordLengths()
      A class with length in bytes of key-entry elements
      Returns:
      lengths of record's elements
    • toString

      public String toString()
      Description copied from class: FixSizeEntry
      Provides an explicit string representation of the entry location
      Overrides:
      toString in class FixSizeEntry
    • sync

      public boolean sync(boolean value)
      Manages if the var size block should be initialized when the entry is selected
      Parameters:
      value - true if the block should be initialized when the entry is changed
      Returns:
      previous value of sync mode
    • moveTo

      public void moveTo(int index)
      Sets the current index to the value as provided.

      The function would mark the entry as invalid if the index does not lay withing the boundaries: 0..ValidatingEntry.getEntriesNumber()

      Overrides:
      moveTo in class ValidatingEntry
      Parameters:
      index - the index to be set
    • getKeyBlockIndex

      public long getKeyBlockIndex()
      Reads the key block index from the current entry
      Returns:
      key block index
    • getId

      public long getId()
      Reads an id associated with the current entry
      Returns:
      the id as it stored in the entry
    • setRecord

      public void setRecord(Record record)
      Put record to the current position / entry
      Parameters:
      record - the record to write to the key entry
    • getRecord

      public Record getRecord()
      Reads the record from the current position
      Returns:
      the record object
    • isExpired

      public boolean isExpired()
      Checks if current entry is expired (according to EOL)
      Returns:
      true if the entry already expired
    • isExpired

      public boolean isExpired(long currentTimeSecs)
      Checks if current entry is expired (according to EOL)
      Parameters:
      currentTimeSecs - current timestamp in seconds
      Returns:
      true if the entry expired according to the given timestamp
    • setKeyBlockIndex

      public void setKeyBlockIndex(long blockIndex)
      Sets the key block to the provided index
      Parameters:
      blockIndex - the block index
    • getKeyBlockOffset

      public long getKeyBlockOffset()
      Provides an offset of the key in the key block
      Returns:
      the offset within the key block
    • setKeyBlockOffset

      public void setKeyBlockOffset(long offset)
      Sets offset of the key in the key block
      Parameters:
      offset - the offset to associate with the key
    • incKeyBlockOffset

      public void incKeyBlockOffset(long add)
      Increments the offset associated with the key by provided increment
      Parameters:
      add - how much to increment
    • getEntrySize

      public int getEntrySize()
      Provides an entry size in bytes
      Specified by:
      getEntrySize in class FixSizeEntry
      Returns:
      the entry size in bytes