public class InMemoryKeyValueLoggedStore<K,V> extends WrappedStateStore.AbstractStateStore implements KeyValueStore<K,V>
WrappedStateStore.AbstractStateStore
Constructor and Description |
---|
InMemoryKeyValueLoggedStore(KeyValueStore<K,V> inner,
org.apache.kafka.common.serialization.Serde<K> keySerde,
org.apache.kafka.common.serialization.Serde<V> valueSerde) |
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 |
delete(K key)
Delete the value from the store (if there is one).
|
V |
get(K key)
Get the value corresponding to this key.
|
void |
init(ProcessorContext context,
StateStore root)
Initializes this state store.
|
void |
put(K key,
V value)
Update the value associated with this key.
|
void |
putAll(java.util.List<KeyValue<K,V>> entries)
Update all the given key/value pairs.
|
V |
putIfAbsent(K key,
V value)
Update the value associated with this key, unless a value is already associated with the key.
|
KeyValueIterator<K,V> |
range(K from,
K to)
Get an iterator over a given range of keys.
|
protected void |
removed(K key)
Called when the underlying
inner KeyValueStore removes an entry in response to a call from this
store. |
close, flush, inner, isOpen, name, persistent, wrappedStore
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, flush, isOpen, name, persistent
public InMemoryKeyValueLoggedStore(KeyValueStore<K,V> inner, org.apache.kafka.common.serialization.Serde<K> keySerde, org.apache.kafka.common.serialization.Serde<V> valueSerde)
public void init(ProcessorContext context, StateStore root)
StateStore
The implementation of this function must register the root store in the context via the
ProcessorContext.register(StateStore, StateRestoreCallback)
function, where the
first StateStore
parameter should always be the passed-in root
object, and
the second parameter should be an object of user's implementation
of the StateRestoreCallback
interface used for restoring the state store from the changelog.
Note that if the state store engine itself supports bulk writes, users can implement another
interface BatchingStateRestoreCallback
which extends StateRestoreCallback
to
let users implement bulk-load restoration logic instead of restoring one record at a time.
init
in interface StateStore
init
in class WrappedStateStore.AbstractStateStore
public long approximateNumEntries()
ReadOnlyKeyValueStore
approximateNumEntries
in interface ReadOnlyKeyValueStore<K,V>
public V get(K key)
ReadOnlyKeyValueStore
get
in interface ReadOnlyKeyValueStore<K,V>
key
- The key to fetchpublic void put(K key, V value)
KeyValueStore
put
in interface KeyValueStore<K,V>
key
- The key to associate the value tovalue
- The value to update, it can be null
;
if the serialized bytes are also null
it is interpreted as deletespublic V putIfAbsent(K key, V value)
KeyValueStore
putIfAbsent
in interface KeyValueStore<K,V>
key
- The key to associate the value tovalue
- The value to update, it can be null
;
if the serialized bytes are also null
it is interpreted as deletesnull
if there is no such key.public void putAll(java.util.List<KeyValue<K,V>> entries)
KeyValueStore
putAll
in interface KeyValueStore<K,V>
entries
- A list of entries to put into the store;
if the serialized bytes are also null
it is interpreted as deletespublic V delete(K key)
KeyValueStore
delete
in interface KeyValueStore<K,V>
key
- The keynull
if there is no such key.protected void removed(K key)
inner
KeyValueStore
removes an entry in response to a call from this
store.key
- the key for the entry that the inner store removedpublic KeyValueIterator<K,V> range(K from, K to)
ReadOnlyKeyValueStore
ConcurrentModificationException
s
and must not return null values. No ordering guarantees are provided.range
in interface ReadOnlyKeyValueStore<K,V>
from
- The first key that could be in the rangeto
- The last key that could be in the rangepublic KeyValueIterator<K,V> all()
ReadOnlyKeyValueStore
ConcurrentModificationException
s
and must not return null values. No ordering guarantees are provided.all
in interface ReadOnlyKeyValueStore<K,V>