Class ChangeLoggingKeyValueBytesStore
- java.lang.Object
-
- org.apache.kafka.streams.state.internals.WrappedStateStore<KeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>,byte[],byte[]>
-
- org.apache.kafka.streams.state.internals.ChangeLoggingKeyValueBytesStore
-
- All Implemented Interfaces:
StateStore,CachedStateStore<byte[],byte[]>,KeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>,ReadOnlyKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>
- Direct Known Subclasses:
ChangeLoggingTimestampedKeyValueBytesStore
public class ChangeLoggingKeyValueBytesStore extends WrappedStateStore<KeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>,byte[],byte[]> implements KeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]>all()Return an iterator over all keys in this store.longapproximateNumEntries()Return an approximate count of key-value mappings in this store.byte[]delete(org.apache.kafka.common.utils.Bytes key)Delete the value from the store (if there is one).byte[]get(org.apache.kafka.common.utils.Bytes key)Get the value corresponding to this key.voidinit(ProcessorContext context, StateStore root)Initializes this state store.voidput(org.apache.kafka.common.utils.Bytes key, byte[] value)Update the value associated with this key.voidputAll(java.util.List<KeyValue<org.apache.kafka.common.utils.Bytes,byte[]>> entries)Update all the given key/value pairs.byte[]putIfAbsent(org.apache.kafka.common.utils.Bytes key, byte[] value)Update the value associated with this key, unless a value is already associated with the key.KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]>range(org.apache.kafka.common.utils.Bytes from, org.apache.kafka.common.utils.Bytes to)Get an iterator over a given range of keys.-
Methods inherited from class org.apache.kafka.streams.state.internals.WrappedStateStore
close, flush, isOpen, isTimestamped, name, persistent, setFlushListener, wrapped
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.kafka.streams.processor.StateStore
close, flush, isOpen, name, persistent
-
-
-
-
Method Detail
-
init
public void init(ProcessorContext context, StateStore root)
Description copied from interface:StateStoreInitializes this state store.The implementation of this function must register the root store in the context via the
ProcessorContext.register(StateStore, StateRestoreCallback)function, where the firstStateStoreparameter should always be the passed-inrootobject, and the second parameter should be an object of user's implementation of theStateRestoreCallbackinterface 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
BatchingStateRestoreCallbackwhich extendsStateRestoreCallbackto let users implement bulk-load restoration logic instead of restoring one record at a time.- Specified by:
initin interfaceStateStore- Overrides:
initin classWrappedStateStore<KeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>,byte[],byte[]>
-
approximateNumEntries
public long approximateNumEntries()
Description copied from interface:ReadOnlyKeyValueStoreReturn 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.- Specified by:
approximateNumEntriesin interfaceReadOnlyKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- Returns:
- an approximate count of key-value mappings in the store.
-
put
public void put(org.apache.kafka.common.utils.Bytes key, byte[] value)Description copied from interface:KeyValueStoreUpdate the value associated with this key.- Specified by:
putin interfaceKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- Parameters:
key- The key to associate the value tovalue- The value to update, it can benull; if the serialized bytes are alsonullit is interpreted as deletes
-
putIfAbsent
public byte[] putIfAbsent(org.apache.kafka.common.utils.Bytes key, byte[] value)Description copied from interface:KeyValueStoreUpdate the value associated with this key, unless a value is already associated with the key.- Specified by:
putIfAbsentin interfaceKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- Parameters:
key- The key to associate the value tovalue- The value to update, it can benull; if the serialized bytes are alsonullit is interpreted as deletes- Returns:
- The old value or
nullif there is no such key.
-
putAll
public void putAll(java.util.List<KeyValue<org.apache.kafka.common.utils.Bytes,byte[]>> entries)
Description copied from interface:KeyValueStoreUpdate all the given key/value pairs.- Specified by:
putAllin interfaceKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- Parameters:
entries- A list of entries to put into the store; if the serialized bytes are alsonullit is interpreted as deletes
-
delete
public byte[] delete(org.apache.kafka.common.utils.Bytes key)
Description copied from interface:KeyValueStoreDelete the value from the store (if there is one).- Specified by:
deletein interfaceKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- Parameters:
key- The key- Returns:
- The old value or
nullif there is no such key.
-
get
public byte[] get(org.apache.kafka.common.utils.Bytes key)
Description copied from interface:ReadOnlyKeyValueStoreGet the value corresponding to this key.- Specified by:
getin interfaceReadOnlyKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- Parameters:
key- The key to fetch- Returns:
- The value or null if no value is found.
-
range
public KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]> range(org.apache.kafka.common.utils.Bytes from, org.apache.kafka.common.utils.Bytes to)
Description copied from interface:ReadOnlyKeyValueStoreGet an iterator over a given range of keys. This iterator must be closed after use. The returned iterator must be safe fromConcurrentModificationExceptions and must not return null values. No ordering guarantees are provided.- Specified by:
rangein interfaceReadOnlyKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- 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.
-
all
public KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]> all()
Description copied from interface:ReadOnlyKeyValueStoreReturn an iterator over all keys in this store. This iterator must be closed after use. The returned iterator must be safe fromConcurrentModificationExceptions and must not return null values. No ordering guarantees are provided.- Specified by:
allin interfaceReadOnlyKeyValueStore<org.apache.kafka.common.utils.Bytes,byte[]>- Returns:
- An iterator of all key/value pairs in the store.
-
-