Package org.apache.kafka.streams.state
Interface ReadOnlyKeyValueStore<K,V>
-
- Type Parameters:
K
- the key typeV
- the value type
- All Known Subinterfaces:
KeyValueStore<K,V>
,Segment
,TimestampedKeyValueStore<K,V>
- All Known Implementing Classes:
CachingKeyValueStore
,ChangeLoggingKeyValueBytesStore
,ChangeLoggingTimestampedKeyValueBytesStore
,CompositeReadOnlyKeyValueStore
,InMemoryKeyValueStore
,KeyValueStoreFacade
,KeyValueToTimestampedKeyValueByteStoreAdapter
,MemoryLRUCache
,MemoryNavigableLRUCache
,MeteredKeyValueStore
,MeteredTimestampedKeyValueStore
,ReadOnlyKeyValueStoreFacade
,RocksDBStore
,RocksDBTimestampedStore
public interface ReadOnlyKeyValueStore<K,V>
A key-value store that only supports read operations. Implementations should be thread-safe as concurrent reads and writes are expected. 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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
get
V get(K key)
Get the value corresponding to this key.- Parameters:
key
- The key to fetch- Returns:
- The value or null if no value is found.
- Throws:
NullPointerException
- If null is used for key.InvalidStateStoreException
- if the store is not initialized
-
range
KeyValueIterator<K,V> range(K from, K to)
Get an iterator over a given range of keys. This iterator must be closed after use. The returned iterator must be safe fromConcurrentModificationException
s and must not return null values. No ordering guarantees are provided.- Parameters:
from
- The first key that could be in the rangeto
- The last key that could be in the range- Returns:
- The iterator for this range.
- Throws:
NullPointerException
- If null is used for from or to.InvalidStateStoreException
- if the store is not initialized
-
all
KeyValueIterator<K,V> all()
Return an iterator over all keys in this store. This iterator must be closed after use. The returned iterator must be safe fromConcurrentModificationException
s and must not return null values. No ordering guarantees are provided.- Returns:
- An iterator of all key/value pairs in the store.
- Throws:
InvalidStateStoreException
- if the store is not initialized
-
approximateNumEntries
long approximateNumEntries()
Return an approximate count of key-value mappings in this store. The count is not guaranteed to be exact in order to accommodate stores where an exact count is expensive to calculate.- Returns:
- an approximate count of key-value mappings in the store.
- Throws:
InvalidStateStoreException
- if the store is not initialized
-
-