public class MeteredSessionStore<K,V> extends WrappedStateStore.AbstractStateStore implements SessionStore<K,V>
WrappedStateStore.AbstractStateStore
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the storage engine.
|
KeyValueIterator<Windowed<K>,V> |
fetch(K key)
Retrieve all aggregated sessions for the provided key.
|
KeyValueIterator<Windowed<K>,V> |
fetch(K from,
K to)
Retrieve all aggregated sessions for the given range of keys.
|
KeyValueIterator<Windowed<K>,V> |
findSessions(K keyFrom,
K keyTo,
long earliestSessionEndTime,
long latestSessionStartTime)
Fetch any sessions in the given range of keys and the sessions end is ≥ earliestSessionEndTime and the sessions
start is ≤ latestSessionStartTime
This iterator must be closed after use.
|
KeyValueIterator<Windowed<K>,V> |
findSessions(K key,
long earliestSessionEndTime,
long latestSessionStartTime)
Fetch any sessions with the matching key and the sessions end is ≥ earliestSessionEndTime and the sessions
start is ≤ latestSessionStartTime
This iterator must be closed after use.
|
void |
flush()
Flush any cached data
|
void |
init(ProcessorContext context,
StateStore root)
Initializes this state store.
|
void |
put(Windowed<K> sessionKey,
V aggregate)
Write the aggregated value for the provided key to the store
|
void |
remove(Windowed<K> sessionKey)
Remove the session aggregated with provided
Windowed key from the store |
inner, isOpen, name, persistent, wrappedStore
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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 close()
StateStore
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
close
in interface StateStore
close
in class WrappedStateStore.AbstractStateStore
public KeyValueIterator<Windowed<K>,V> findSessions(K key, long earliestSessionEndTime, long latestSessionStartTime)
SessionStore
findSessions
in interface SessionStore<K,V>
key
- the key to return sessions forearliestSessionEndTime
- the end timestamp of the earliest session to search forlatestSessionStartTime
- the end timestamp of the latest session to search forpublic KeyValueIterator<Windowed<K>,V> findSessions(K keyFrom, K keyTo, long earliestSessionEndTime, long latestSessionStartTime)
SessionStore
findSessions
in interface SessionStore<K,V>
keyFrom
- The first key that could be in the rangekeyTo
- The last key that could be in the rangeearliestSessionEndTime
- the end timestamp of the earliest session to search forlatestSessionStartTime
- the end timestamp of the latest session to search forpublic void remove(Windowed<K> sessionKey)
SessionStore
Windowed
key from the storeremove
in interface SessionStore<K,V>
sessionKey
- key of the session to removepublic void put(Windowed<K> sessionKey, V aggregate)
SessionStore
put
in interface SessionStore<K,V>
sessionKey
- key of the session to writeaggregate
- the aggregated value for the session, it can be null;
if the serialized bytes are also null it is interpreted as deletespublic KeyValueIterator<Windowed<K>,V> fetch(K key)
ReadOnlySessionStore
fetch
in interface ReadOnlySessionStore<K,V>
key
- record key to find aggregated session values forpublic KeyValueIterator<Windowed<K>,V> fetch(K from, K to)
ReadOnlySessionStore
fetch
in interface ReadOnlySessionStore<K,V>
from
- first key in the range to find aggregated session values forto
- last key in the range to find aggregated session values forpublic void flush()
StateStore
flush
in interface StateStore
flush
in class WrappedStateStore.AbstractStateStore