Interface ColumnFamily<KeyType extends DbKey,ValueType extends DbValue>

Type Parameters:
KeyType - the type of the keys
ValueType - the type of the values

public interface ColumnFamily<KeyType extends DbKey,ValueType extends DbValue>
Represents an column family, where it is possible to store keys of type ColumnFamily and corresponding values of type ColumnFamily.
  • Method Details

    • insert

      void insert(KeyType key, ValueType value)
      Inserts a new key value pair into the column family.
      Throws:
      IllegalStateException - if key already exists
    • update

      void update(KeyType key, ValueType value)
      Updates the value of an existing key in the column family.
      Throws:
      IllegalStateException - if key does not exist
    • upsert

      void upsert(KeyType key, ValueType value)
      Inserts or updates a key value pair in the column family.
    • get

      ValueType get(KeyType key)
      The corresponding stored value in the column family to the given key.
      Parameters:
      key - the key
      Returns:
      if the key was found in the column family then the value, otherwise null
    • forEach

      void forEach(Consumer<ValueType> consumer)
      Visits the values, which are stored in the column family. The ordering depends on the key.

      The given consumer accepts the values. Be aware that the given DbValue wraps the stored value and reflects the current iteration step. The DbValue should not be stored, since it will change his internal value during iteration.

      Parameters:
      consumer - the consumer which accepts the value
    • forEach

      void forEach(BiConsumer<KeyType,ValueType> consumer)
      Visits the key-value pairs, which are stored in the column family. The ordering depends on the key.

      Similar to forEach(Consumer).

      Parameters:
      consumer - the consumer which accepts the key-value pairs
    • whileTrue

      void whileTrue(KeyValuePairVisitor<KeyType,ValueType> visitor)
      Visits the key-value pairs, which are stored in the column family. The ordering depends on the key. The visitor can indicate via the return value, whether the iteration should continue or not. This means if the visitor returns false the iteration will stop.

      Similar to forEach(BiConsumer).

      Parameters:
      visitor - the visitor which visits the key-value pairs
    • whileEqualPrefix

      void whileEqualPrefix(DbKey keyPrefix, BiConsumer<KeyType,ValueType> visitor)
      Visits the key-value pairs, which are stored in the column family and which have the same common prefix. The ordering depends on the key.

      Similar to forEach(BiConsumer).

      Parameters:
      keyPrefix - the prefix which should have the keys in common
      visitor - the visitor which visits the key-value pairs
    • whileEqualPrefix

      void whileEqualPrefix(DbKey keyPrefix, KeyValuePairVisitor<KeyType,ValueType> visitor)
      Visits the key-value pairs, which are stored in the column family and which have the same common prefix. The ordering depends on the key. The visitor can indicate via the return value, whether the iteration should continue or * not. This means if the visitor returns false the iteration will stop.

      Similar to and #whileTrue(KeyValuePairVisitor).

      Parameters:
      keyPrefix - the prefix which should have the keys in common
      visitor - the visitor which visits the key-value pairs
    • deleteExisting

      void deleteExisting(KeyType key)
      Deletes the key-value pair with the given key if it exists in the column family
      Throws:
      IllegalStateException - if the key does not exist
    • deleteIfExists

      void deleteIfExists(KeyType key)
      Deletes the key-value pair if the key does exist in the column family. No-op if the key does not exist.
    • exists

      boolean exists(KeyType key)
      Checks for key existence in the column family.
      Parameters:
      key - the key to look for
      Returns:
      true if the key exist in this column family, false otherwise
    • isEmpty

      boolean isEmpty()
      Checks if the column family has any entry.
      Returns:
      true if the column family has no entry