Package org.apache.kafka.streams.state
Interface SessionStore<K,AGG>
- Type Parameters:
K- type of the record keysAGG- type of the aggregated values
- All Superinterfaces:
ReadOnlySessionStore<K,AGG>,StateStore
public interface SessionStore<K,AGG> extends StateStore, ReadOnlySessionStore<K,AGG>
Interface for storing the aggregated values of sessions.
The key is internally represented as Windowed<K> that comprises the plain
key and the Window that represents window start- and end-timestamp.
If two sessions are merged, a new session with new start- and end-timestamp must be inserted into the store while the two old sessions must be deleted.
-
Method Summary
Modifier and Type Method Description default KeyValueIterator<Windowed<K>,AGG>backwardFindSessions(K key, Instant earliestSessionEndTime, Instant latestSessionStartTime)Fetch any sessions with the matching key and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from latest to earliest.default KeyValueIterator<Windowed<K>,AGG>backwardFindSessions(K keyFrom, K keyTo, Instant earliestSessionEndTime, Instant latestSessionStartTime)Fetch any sessions in the given range of keys and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from latest to earliest.default AGGfetchSession(K key, Instant earliestSessionEndTime, Instant latestSessionStartTime)Get the value of key from a single session.default KeyValueIterator<Windowed<K>,AGG>findSessions(K key, Instant earliestSessionEndTime, Instant latestSessionStartTime)Fetch any sessions with the matching key and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from earliest to latest.default KeyValueIterator<Windowed<K>,AGG>findSessions(K keyFrom, K keyTo, Instant earliestSessionEndTime, Instant latestSessionStartTime)Fetch any sessions in the given range of keys and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from earliest to latest.voidput(Windowed<K> sessionKey, AGG aggregate)Write the aggregated value for the provided key to the storevoidremove(Windowed<K> sessionKey)Remove the session aggregated with providedWindowedkey from the storeMethods inherited from interface org.apache.kafka.streams.state.ReadOnlySessionStore
backwardFetch, backwardFetch, backwardFindSessions, backwardFindSessions, fetch, fetch, fetchSession, findSessions, findSessionsMethods inherited from interface org.apache.kafka.streams.processor.StateStore
close, flush, init, init, isOpen, name, persistent
-
Method Details
-
findSessions
default KeyValueIterator<Windowed<K>,AGG> findSessions(K key, Instant earliestSessionEndTime, Instant latestSessionStartTime)Description copied from interface:ReadOnlySessionStoreFetch any sessions with the matching key and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from earliest to latest.This iterator must be closed after use.
- Specified by:
findSessionsin interfaceReadOnlySessionStore<K,AGG>- Parameters:
key- the key to return sessions forearliestSessionEndTime- the end timestamp of the earliest session to search for, where iteration starts.latestSessionStartTime- the end timestamp of the latest session to search for, where iteration ends.- Returns:
- iterator of sessions with the matching key and aggregated values, from earliest to latest session time.
-
backwardFindSessions
default KeyValueIterator<Windowed<K>,AGG> backwardFindSessions(K key, Instant earliestSessionEndTime, Instant latestSessionStartTime)Description copied from interface:ReadOnlySessionStoreFetch any sessions with the matching key and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from latest to earliest.This iterator must be closed after use.
- Specified by:
backwardFindSessionsin interfaceReadOnlySessionStore<K,AGG>- Parameters:
key- the key to return sessions forearliestSessionEndTime- the end timestamp of the earliest session to search for, where iteration ends.latestSessionStartTime- the end timestamp of the latest session to search for, where iteration starts.- Returns:
- backward iterator of sessions with the matching key and aggregated values, from latest to earliest session time.
-
findSessions
default KeyValueIterator<Windowed<K>,AGG> findSessions(K keyFrom, K keyTo, Instant earliestSessionEndTime, Instant latestSessionStartTime)Description copied from interface:ReadOnlySessionStoreFetch any sessions in the given range of keys and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from earliest to latest.This iterator must be closed after use.
- Specified by:
findSessionsin interfaceReadOnlySessionStore<K,AGG>- Parameters:
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 for, where iteration starts.latestSessionStartTime- the end timestamp of the latest session to search for, where iteration ends.- Returns:
- iterator of sessions with the matching keys and aggregated values, from earliest to latest session time.
-
backwardFindSessions
default KeyValueIterator<Windowed<K>,AGG> backwardFindSessions(K keyFrom, K keyTo, Instant earliestSessionEndTime, Instant latestSessionStartTime)Description copied from interface:ReadOnlySessionStoreFetch any sessions in the given range of keys and the sessions end is ≥ earliestSessionEndTime and the sessions start is ≤ latestSessionStartTime iterating from latest to earliest.This iterator must be closed after use.
- Specified by:
backwardFindSessionsin interfaceReadOnlySessionStore<K,AGG>- Parameters:
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 for, where iteration ends.latestSessionStartTime- the end timestamp of the latest session to search for, where iteration starts.- Returns:
- backward iterator of sessions with the matching keys and aggregated values, from latest to earliest session time.
-
fetchSession
Description copied from interface:ReadOnlySessionStoreGet the value of key from a single session.- Specified by:
fetchSessionin interfaceReadOnlySessionStore<K,AGG>- Parameters:
key- the key to fetchearliestSessionEndTime- start timestamp of the sessionlatestSessionStartTime- end timestamp of the session- Returns:
- The value or
nullif no session associated with the key can be found
-
remove
Remove the session aggregated with providedWindowedkey from the store- Parameters:
sessionKey- key of the session to remove- Throws:
NullPointerException- If null is used for sessionKey.
-
put
Write the aggregated value for the provided key to the store- Parameters:
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 deletes- Throws:
NullPointerException- If null is used for sessionKey.
-