Class FixSizeEntry
- Direct Known Subclasses:
CatalogBlockEntry
,KeyBlockEntry
This object contains the reference of the block within the sequence, so it specifies a specific entry within the sequence.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
expand()
Creates an entry at the end of the current block.int
Get the number of entries that exist in the block.protected int
Provides a pointer of the start of the entry within the block in bytesabstract int
Provides an entry size in bytesProvides the block abstraction this entry is created withlong
getHash()
Returns a hash of the current location of the entry, which encompasses with the index of the block and the index of the entry.void
insert()
Allocates an entry at the current index.void
moveToHash
(long hash) Moves the location of the current entry to the previously stored hash (seegetHash()
).void
remove()
Removes current entry and collapses the space it used.toString()
Provides an explicit string representation of the entry locationMethods inherited from class org.rostore.v2.fixsize.ValidatingEntry
first, getIndex, invalid, invalidate, isFirst, last, moveTo, next, previous, throwExceptionIfInvalid, valid, validate
-
Constructor Details
-
FixSizeEntry
Initializes the entry- Parameters:
fixSizeEntryBlock
- a block abstraction to be used for entries
-
-
Method Details
-
getEntriesNumber
public int getEntriesNumber()Get the number of entries that exist in the block.It is not to mix to capacity, and represents a total number of entries added to this block by now.
- Specified by:
getEntriesNumber
in classValidatingEntry
- Returns:
- the number of entries
-
getHash
public long getHash()Returns a hash of the current location of the entry, which encompasses with the index of the block and the index of the entry.Please note that the has can only be used if the block sequence is not changed.
It also assumes that the number of blocks in the sequence and the number of entries in each block is not bigger that the 32bit.
- Returns:
- the hash that identifies the position of the selected entry in the sequence
-
moveToHash
public void moveToHash(long hash) Moves the location of the current entry to the previously stored hash (seegetHash()
).- Parameters:
hash
- the hash to move to
-
toString
Provides an explicit string representation of the entry location- Overrides:
toString
in classValidatingEntry
-
getFixSizeEntryBlock
Provides the block abstraction this entry is created with- Returns:
- the block
-
getEntryLocation
protected int getEntryLocation()Provides a pointer of the start of the entry within the block in bytesIt validates if the entry is valid and throws an exception otherwise.
- Returns:
- the byte location of the entry within the body of the block
-
expand
public void expand()Creates an entry at the end of the current block.It will throw an exception in case the capacity of the block does not allow to expand it.
The number of entries will be increased.
The new index will be set to the last entry.
This operation will not validate the entry as it may be executed on the block without any entry (invalid one!)
-
remove
public void remove()Removes current entry and collapses the space it used.All the entries that follows the current one will be moved up by one entry size.
It will validate the current entry and throw an exception if the entry is invalid.
-
insert
public void insert()Allocates an entry at the current index.All the entries at the current position to the end of the block are moved down the block body.
The function will validate if the entry location is valid and throw an exception otherwise.
It will not validate if the capacity is enough. Caller is responsible for it.
-
getEntrySize
public abstract int getEntrySize()Provides an entry size in bytes- Returns:
- the entry size in bytes
-