Class Record

java.lang.Object
org.rostore.entity.Record

public class Record extends Object
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 Details

    • Record

      public Record()
  • Method Details

    • ttlOrUnitEol

      public Record ttlOrUnitEol(Long ttl, Long unixEol)
      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 or null
      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

      public Record id(long 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

      public Record ttl(long ttl)
    • eol

      public Record eol(long 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 version

      Function 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

      public Record version(long version)
      Sets a version to the record
      Parameters:
      version - a version to be set
      Returns:
      the record object
    • hasOption

      public boolean hasOption(RecordOption option)
      Checks if the record contains a provided option
      Parameters:
      option - an option to lookup
      Returns:
      true if option is available
    • addOption

      public Record addOption(RecordOption recordOption)
      Adds an option to the record object
      Parameters:
      recordOption - an option to add
      Returns:
      the record object
    • addOptions

      public Record addOptions(Set<RecordOption> recordOptions)
      Adds a set of options to the record object
      Parameters:
      recordOptions - an option set to add
      Returns:
      the record object