Package org.rostore.v2.keys
Class KeyBlockEntry
java.lang.Object
org.rostore.v2.fixsize.ValidatingEntry
org.rostore.v2.fixsize.FixSizeEntry
org.rostore.v2.keys.KeyBlockEntry
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 Summary
ModifierConstructorDescriptionprotected
KeyBlockEntry
(FixSizeEntryBlock<KeyBlockEntry> keyBlock, VarSizeBlock varSizeBlock, RecordLengths recordLengths) -
Method Summary
Modifier and TypeMethodDescriptionint
Provides an entry size in byteslong
getId()
Reads an id associated with the current entrylong
Reads the key block index from the current entrylong
Provides an offset of the key in the key blockReads the record from the current positionA class with length in bytes of key-entry elementsvoid
incKeyBlockOffset
(long add) Increments the offset associated with the key by provided incrementboolean
Checks if current entry is expired (according to EOL)boolean
isExpired
(long currentTimeSecs) Checks if current entry is expired (according to EOL)void
moveTo
(int index) Sets the current index to the value as provided.void
setKeyBlockIndex
(long blockIndex) Sets the key block to the provided indexvoid
setKeyBlockOffset
(long offset) Sets offset of the key in the key blockvoid
Put record to the current position / entryboolean
sync
(boolean value) Manages if the var size block should be initialized when the entry is selectedtoString()
Provides an explicit string representation of the entry locationMethods inherited from class org.rostore.v2.fixsize.FixSizeEntry
expand, getEntriesNumber, getEntryLocation, getFixSizeEntryBlock, getHash, insert, moveToHash, remove
Methods inherited from class org.rostore.v2.fixsize.ValidatingEntry
first, getIndex, invalid, invalidate, isFirst, last, next, previous, throwExceptionIfInvalid, valid, validate
-
Constructor Details
-
KeyBlockEntry
protected KeyBlockEntry(FixSizeEntryBlock<KeyBlockEntry> keyBlock, VarSizeBlock varSizeBlock, RecordLengths recordLengths)
-
-
Method Details
-
getRecordLengths
A class with length in bytes of key-entry elements- Returns:
- lengths of record's elements
-
toString
Description copied from class:FixSizeEntry
Provides an explicit string representation of the entry location- Overrides:
toString
in classFixSizeEntry
-
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 classValidatingEntry
- 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
Put record to the current position / entry- Parameters:
record
- the record to write to the key entry
-
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 classFixSizeEntry
- Returns:
- the entry size in bytes
-