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 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.void
close()
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.void
flush()
Flush any cached databyte[]
get(org.apache.kafka.common.utils.Bytes key)
Get the record from the store with the given key.void
init(ProcessorContext context, StateStore root)
Initializes this state store.boolean
isOpen()
Is this store open for reading and writingString
name()
The name of this store.boolean
persistent()
Return if the storage is persistent or not.void
put(org.apache.kafka.common.utils.Bytes key, byte[] value)
Write a new value to the store with the provided key.void
remove(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:SegmentedBytesStore
Fetch all records from the segmented store with the provided key and time range from all existing segments- Specified by:
fetch
in 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:SegmentedBytesStore
Fetch all records from the segmented store in the provided key range and time range from all existing segments- Specified by:
fetch
in 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:SegmentedBytesStore
Gets all the key-value pairs in the existing windows.- Specified by:
all
in 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:SegmentedBytesStore
Gets all the key-value pairs that belong to the windows within in the given time range.- Specified by:
fetchAll
in 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:SegmentedBytesStore
Remove 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:
remove
in 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:SegmentedBytesStore
Write 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:
put
in interfaceSegmentedBytesStore
-
get
public byte[] get(org.apache.kafka.common.utils.Bytes key)
Description copied from interface:SegmentedBytesStore
Get 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:
get
in interfaceSegmentedBytesStore
- Returns:
-
name
public String name()
Description copied from interface:StateStore
The name of this store.- Specified by:
name
in interfaceStateStore
- Returns:
- the storage name
-
init
public void init(ProcessorContext context, StateStore root)
Description copied from interface:StateStore
Initializes 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 firstStateStore
parameter should always be the passed-inroot
object, and the second parameter should be an object of user's implementation of theStateRestoreCallback
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 extendsStateRestoreCallback
to let users implement bulk-load restoration logic instead of restoring one record at a time.- Specified by:
init
in interfaceStateStore
-
flush
public void flush()
Description copied from interface:StateStore
Flush any cached data- Specified by:
flush
in interfaceStateStore
-
close
public void close()
Description copied from interface:StateStore
Close 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:
close
in interfaceStateStore
-
persistent
public boolean persistent()
Description copied from interface:StateStore
Return if the storage is persistent or not.- Specified by:
persistent
in interfaceStateStore
- Returns:
true
if the storage is persistent—false
otherwise
-
isOpen
public boolean isOpen()
Description copied from interface:StateStore
Is this store open for reading and writing- Specified by:
isOpen
in interfaceStateStore
- Returns:
true
if the store is open
-
-