Package org.rostore.entity
Class Record
java.lang.Object
org.rostore.entity.Record
Record describes the payload associated with the key in the storage.
It contains the metadata like TTL, version and id.
id is an arbitrary long, but is usually used to reference the block index where the value is stored.
Record also contains the set of options that should be considered on the key-specific operations.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddOption
(RecordOption recordOption) Adds an option to the record objectaddOptions
(Set<RecordOption> recordOptions) Adds a set of options to the record objecteol
(long eol) Sets end of live of the recordlong
getEol()
Returns end of life as it stored in the recordlong
getId()
The Id associated with the key-value pair.long
getTtl()
Gets ttl is secondslong
Calculates the end of life in terms of unix epoclong
Provides a version as set to recordboolean
hasOption
(RecordOption option) Checks if the record contains a provided optionid
(long id) Sets the id to be stored with the record.void
incrementVersion
(int lengthBytes) Increment versionttl
(long ttl) ttlOrUnitEol
(Long ttl, Long unixEol) Creates a record based on ttl or unixEol provided.version
(long version) Sets a version to the record
-
Constructor Details
-
Record
public Record()
-
-
Method Details
-
ttlOrUnitEol
Creates a record based on ttl or unixEol provided.This is a helper function and can be used in the situations when either/or of these to parametrrs are given.
- Parameters:
ttl
- a ttl - time to live ornull
unixEol
- a unix timestamp until this record should be valid- Returns:
- the record object
-
getId
public long getId()The Id associated with the key-value pair.- Returns:
- the id
-
id
Sets the id to be stored with the record.- Parameters:
id
- the id- Returns:
- the record object
-
getUnixEol
public long getUnixEol()Calculates the end of life in terms of unix epoc- Returns:
- the unix timestamp when the record will expire or 0 if the object is not expected to expire
-
getTtl
public long getTtl()Gets ttl is seconds- Returns:
- the ttl in seconds
-
getEol
public long getEol()Returns end of life as it stored in the record- Returns:
- the eof of the record
-
ttl
-
eol
Sets end of live of the record- Parameters:
eol
- the eol of the record- Returns:
- the record object
-
incrementVersion
public void incrementVersion(int lengthBytes) Increment versionFunction will trim the counter by the number of bytes
- Parameters:
lengthBytes
- the number of bytes to trim the version
-
getVersion
public long getVersion()Provides a version as set to record- Returns:
- the version
-
version
Sets a version to the record- Parameters:
version
- a version to be set- Returns:
- the record object
-
hasOption
Checks if the record contains a provided option- Parameters:
option
- an option to lookup- Returns:
true
if option is available
-
addOption
Adds an option to the record object- Parameters:
recordOption
- an option to add- Returns:
- the record object
-
addOptions
Adds a set of options to the record object- Parameters:
recordOptions
- an option set to add- Returns:
- the record object
-