K
- the key typeV
- the value typepublic interface ReadOnlyKeyValueStore<K,V>
Please note that this contract defines the thread-safe read functionality only; it does not guarantee anything about whether the actual instance is writable by another thread, or whether it uses some locking mechanism under the hood. For this reason, making dependencies between the read and write operations on different StateStore instances can cause concurrency problems like deadlock.
Modifier and Type | Method and Description |
---|---|
KeyValueIterator<K,V> |
all()
Return an iterator over all keys in this store.
|
long |
approximateNumEntries()
Return an approximate count of key-value mappings in this store.
|
V |
get(K key)
Get the value corresponding to this key.
|
KeyValueIterator<K,V> |
range(K from,
K to)
Get an iterator over a given range of keys.
|
default KeyValueIterator<K,V> |
reverseAll()
Return a reverse iterator over all keys in this store.
|
default KeyValueIterator<K,V> |
reverseRange(K from,
K to)
Get a reverse iterator over a given range of keys.
|
V get(K key)
key
- The key to fetchNullPointerException
- If null is used for key.InvalidStateStoreException
- if the store is not initializedKeyValueIterator<K,V> range(K from, K to)
ConcurrentModificationException
s
and must not return null values.
Order is not guaranteed as bytes lexicographical ordering might not represent key order.from
- The first key that could be in the range, where iteration starts from.to
- The last key that could be in the range, where iteration ends.NullPointerException
- If null is used for from or to.InvalidStateStoreException
- if the store is not initializeddefault KeyValueIterator<K,V> reverseRange(K from, K to)
ConcurrentModificationException
s
and must not return null values.
Order is not guaranteed as bytes lexicographical ordering might not represent key order.from
- The first key that could be in the range, where iteration ends.to
- The last key that could be in the range, where iteration starts from.NullPointerException
- If null is used for from or to.InvalidStateStoreException
- if the store is not initializedKeyValueIterator<K,V> all()
ConcurrentModificationException
s
and must not return null values.
Order is not guaranteed as bytes lexicographical ordering might not represent key order.InvalidStateStoreException
- if the store is not initializeddefault KeyValueIterator<K,V> reverseAll()
ConcurrentModificationException
s
and must not return null values.
Order is not guaranteed as bytes lexicographical ordering might not represent key order.InvalidStateStoreException
- if the store is not initializedlong approximateNumEntries()
The count is not guaranteed to be exact in order to accommodate stores where an exact count is expensive to calculate.
InvalidStateStoreException
- if the store is not initialized