public class RocksDBWindowStore<K,V> extends WrappedStateStore.AbstractStateStore implements WindowStore<K,V>
WrappedStateStore.AbstractStateStore
Modifier and Type | Method and Description |
---|---|
KeyValueIterator<Windowed<K>,V> |
all()
Gets all the key-value pairs in the existing windows.
|
KeyValueIterator<Windowed<K>,V> |
fetch(K from,
K to,
long timeFrom,
long timeTo)
Get all the key-value pairs in the given key range and time range from all the existing windows.
|
V |
fetch(K key,
long timestamp)
Get the value of key from a window.
|
WindowStoreIterator<V> |
fetch(K key,
long timeFrom,
long timeTo)
Get all the key-value pairs with the given key and the time range from all the existing windows.
|
KeyValueIterator<Windowed<K>,V> |
fetchAll(long timeFrom,
long timeTo)
Gets all the key-value pairs that belong to the windows within in the given time range.
|
void |
init(ProcessorContext context,
StateStore root)
Initializes this state store.
|
void |
put(K key,
V value)
Use the current record timestamp as the
windowStartTimestamp and
delegate to WindowStore.put(Object, Object, long) . |
void |
put(K key,
V value,
long windowStartTimestamp)
Put a key-value pair with the given timestamp into the corresponding window
|
close, flush, inner, isOpen, name, persistent, wrappedStore
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fetch, fetch, fetchAll
close, flush, isOpen, name, persistent
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 void put(K key, V value)
WindowStore
windowStartTimestamp
and
delegate to WindowStore.put(Object, Object, long)
.
It's highly recommended to use WindowStore.put(Object, Object, long)
instead, as the record timestamp
is unlikely to be the correct windowStartTimestamp in general.put
in interface WindowStore<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 void put(K key, V value, long windowStartTimestamp)
WindowStore
put
in interface WindowStore<K,V>
key
- The key to associate the value tovalue
- The value; can be nullwindowStartTimestamp
- The timestamp of the beginning of the window to put the key/value intopublic V fetch(K key, long timestamp)
ReadOnlyWindowStore
fetch
in interface ReadOnlyWindowStore<K,V>
key
- the key to fetchtimestamp
- start timestamp (inclusive) of the windownull
if no value is found in the windowpublic WindowStoreIterator<V> fetch(K key, long timeFrom, long timeTo)
WindowStore
This iterator must be closed after use.
The time range is inclusive and applies to the starting timestamp of the window. For example, if we have the following windows:
+-------------------------------+ | key | start time | end time | +-------+------------+----------+ | A | 10 | 20 | +-------+------------+----------+ | A | 15 | 25 | +-------+------------+----------+ | A | 20 | 30 | +-------+------------+----------+ | A | 25 | 35 | +--------------------------------And we call
store.fetch("A", 10, 20)
then the results will contain the first
three windows from the table above, i.e., all those where 10 <= start time <= 20.
For each key, the iterator guarantees ordering of windows, starting from the oldest/earliest available window to the newest/latest window.
fetch
in interface ReadOnlyWindowStore<K,V>
fetch
in interface WindowStore<K,V>
key
- the key to fetchtimeFrom
- time range start (inclusive)timeTo
- time range end (inclusive)<timestamp, value>
public KeyValueIterator<Windowed<K>,V> fetch(K from, K to, long timeFrom, long timeTo)
WindowStore
This iterator must be closed after use.
fetch
in interface ReadOnlyWindowStore<K,V>
fetch
in interface WindowStore<K,V>
from
- the first key in the rangeto
- the last key in the rangetimeFrom
- time range start (inclusive)timeTo
- time range end (inclusive)<Windowed<K>, value>
public KeyValueIterator<Windowed<K>,V> all()
ReadOnlyWindowStore
all
in interface ReadOnlyWindowStore<K,V>
<Windowed<K>, value>
public KeyValueIterator<Windowed<K>,V> fetchAll(long timeFrom, long timeTo)
WindowStore
fetchAll
in interface ReadOnlyWindowStore<K,V>
fetchAll
in interface WindowStore<K,V>
timeFrom
- the beginning of the time slot from which to search (inclusive)timeTo
- the end of the time slot from which to search (inclusive)<Windowed<K>, value>