Package io.camunda.zeebe.db
Interface ColumnFamily<KeyType extends DbKey,ValueType extends DbValue>
- Type Parameters:
KeyType- the type of the keysValueType- the type of the values
Represents an column family, where it is possible to store keys of type
ColumnFamily and
corresponding values of type ColumnFamily.-
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteExisting(KeyType key) Deletes the key-value pair with the given key if it exists in the column familyvoiddeleteIfExists(KeyType key) Deletes the key-value pair if the key does exist in the column family.booleanChecks for key existence in the column family.voidforEach(BiConsumer<KeyType, ValueType> consumer) Visits the key-value pairs, which are stored in the column family.voidVisits the values, which are stored in the column family.The corresponding stored value in the column family to the given key.voidInserts a new key value pair into the column family.booleanisEmpty()Checks if the column family has any entry.voidUpdates the value of an existing key in the column family.voidInserts or updates a key value pair in the column family.voidwhileEqualPrefix(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.voidwhileEqualPrefix(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.voidwhileTrue(KeyValuePairVisitor<KeyType, ValueType> visitor) Visits the key-value pairs, which are stored in the column family.
-
Method Details
-
insert
Inserts a new key value pair into the column family.- Throws:
IllegalStateException- if key already exists
-
update
Updates the value of an existing key in the column family.- Throws:
IllegalStateException- if key does not exist
-
upsert
Inserts or updates a key value pair in the column family. -
get
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
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
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
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
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 commonvisitor- the visitor which visits the key-value pairs
-
whileEqualPrefix
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 commonvisitor- the visitor which visits the key-value pairs
-
deleteExisting
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
Deletes the key-value pair if the key does exist in the column family. No-op if the key does not exist. -
exists
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:
trueif the column family has no entry
-