Class AbstractRocksDBSegmentedBytesStore<S extends Segment>
- java.lang.Object
-
- org.apache.kafka.streams.state.internals.AbstractRocksDBSegmentedBytesStore<S>
-
- All Implemented Interfaces:
StateStore,SegmentedBytesStore
- Direct Known Subclasses:
RocksDBSegmentedBytesStore,RocksDBTimestampedSegmentedBytesStore
public class AbstractRocksDBSegmentedBytesStore<S extends Segment> extends java.lang.Object implements SegmentedBytesStore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.kafka.streams.state.internals.SegmentedBytesStore
SegmentedBytesStore.KeySchema
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]>all()Gets all the key-value pairs in the existing windows.voidclose()Close the storage engine.KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]>fetch(org.apache.kafka.common.utils.Bytes key, long from, long to)Fetch all records from the segmented store with the provided key and time range from all existing segmentsKeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]>fetch(org.apache.kafka.common.utils.Bytes keyFrom, org.apache.kafka.common.utils.Bytes keyTo, long from, long to)Fetch all records from the segmented store in the provided key range and time range from all existing segmentsKeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]>fetchAll(long timeFrom, long timeTo)Gets all the key-value pairs that belong to the windows within in the given time range.voidflush()Flush any cached databyte[]get(org.apache.kafka.common.utils.Bytes key)Get the record from the store with the given key.voidinit(ProcessorContext context, StateStore root)Initializes this state store.booleanisOpen()Is this store open for reading and writingjava.lang.Stringname()The name of this store.booleanpersistent()Return if the storage is persistent or not.voidput(org.apache.kafka.common.utils.Bytes key, byte[] value)Write a new value to the store with the provided key.voidremove(org.apache.kafka.common.utils.Bytes key)Remove the record with the provided key.
-
-
-
Method Detail
-
fetch
public KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]> fetch(org.apache.kafka.common.utils.Bytes key, long from, long to)
Description copied from interface:SegmentedBytesStoreFetch all records from the segmented store with the provided key and time range from all existing segments- Specified by:
fetchin interfaceSegmentedBytesStore- Parameters:
key- the key to matchfrom- earliest time to matchto- latest time to match- Returns:
- an iterator over key-value pairs
-
fetch
public KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]> fetch(org.apache.kafka.common.utils.Bytes keyFrom, org.apache.kafka.common.utils.Bytes keyTo, long from, long to)
Description copied from interface:SegmentedBytesStoreFetch all records from the segmented store in the provided key range and time range from all existing segments- Specified by:
fetchin interfaceSegmentedBytesStore- Parameters:
keyFrom- The first key that could be in the rangekeyTo- The last key that could be in the rangefrom- earliest time to matchto- latest time to match- Returns:
- an iterator over key-value pairs
-
all
public KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]> all()
Description copied from interface:SegmentedBytesStoreGets all the key-value pairs in the existing windows.- Specified by:
allin interfaceSegmentedBytesStore- Returns:
- an iterator over windowed key-value pairs
<Windowed<K>, value>
-
fetchAll
public KeyValueIterator<org.apache.kafka.common.utils.Bytes,byte[]> fetchAll(long timeFrom, long timeTo)
Description copied from interface:SegmentedBytesStoreGets all the key-value pairs that belong to the windows within in the given time range.- Specified by:
fetchAllin interfaceSegmentedBytesStore- Parameters:
timeFrom- the beginning of the time slot from which to searchtimeTo- the end of the time slot from which to search- Returns:
- an iterator over windowed key-value pairs
<Windowed<K>, value>
-
remove
public void remove(org.apache.kafka.common.utils.Bytes key)
Description copied from interface:SegmentedBytesStoreRemove the record with the provided key. The key should be a composite of the record key, and the timestamp information etc as described by theSegmentedBytesStore.KeySchema- Specified by:
removein interfaceSegmentedBytesStore- Parameters:
key- the segmented key to remove
-
put
public void put(org.apache.kafka.common.utils.Bytes key, byte[] value)Description copied from interface:SegmentedBytesStoreWrite a new value to the store with the provided key. The key should be a composite of the record key, and the timestamp information etc as described by theSegmentedBytesStore.KeySchema- Specified by:
putin interfaceSegmentedBytesStore
-
get
public byte[] get(org.apache.kafka.common.utils.Bytes key)
Description copied from interface:SegmentedBytesStoreGet the record from the store with the given key. The key should be a composite of the record key, and the timestamp information etc as described by theSegmentedBytesStore.KeySchema- Specified by:
getin interfaceSegmentedBytesStore- Returns:
-
name
public java.lang.String name()
Description copied from interface:StateStoreThe name of this store.- Specified by:
namein interfaceStateStore- Returns:
- the storage name
-
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
-
flush
public void flush()
Description copied from interface:StateStoreFlush any cached data- Specified by:
flushin interfaceStateStore
-
close
public void close()
Description copied from interface:StateStoreClose the storage engine. Note that this function needs to be idempotent since it may be called several times on the same state store.Users only need to implement this function but should NEVER need to call this api explicitly as it will be called by the library automatically when necessary
- Specified by:
closein interfaceStateStore
-
persistent
public boolean persistent()
Description copied from interface:StateStoreReturn if the storage is persistent or not.- Specified by:
persistentin interfaceStateStore- Returns:
trueif the storage is persistent—falseotherwise
-
isOpen
public boolean isOpen()
Description copied from interface:StateStoreIs this store open for reading and writing- Specified by:
isOpenin interfaceStateStore- Returns:
trueif the store is open
-
-