Interface WindowStore<K,V>
-
- Type Parameters:
K
- Type of keysV
- Type of values
- All Superinterfaces:
ReadOnlyWindowStore<K,V>
,StateStore
- All Known Subinterfaces:
TimestampedWindowStore<K,V>
- All Known Implementing Classes:
InMemoryWindowStore
,MeteredWindowStore
,RocksDBWindowStore
,WindowStoreFacade
public interface WindowStore<K,V> extends StateStore, ReadOnlyWindowStore<K,V>
Interface for storing the aggregated values of fixed-size time windows.Note, that the stores's physical key type is
Windowed<K>
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description 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.default WindowStoreIterator<V>
fetch(K key, Instant from, Instant to)
Get all the key-value pairs with the given key and the time range from all 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.default KeyValueIterator<Windowed<K>,V>
fetch(K from, K to, Instant fromTime, Instant toTime)
Get all the key-value pairs in the given key range and 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.default KeyValueIterator<Windowed<K>,V>
fetchAll(Instant from, Instant to)
Gets all the key-value pairs that belong to the windows within in the given time range.void
put(K key, V value)
Deprecated.as timestamp is not provided for the key-value pair, this causes inconsistency to identify the window frame to which the key belongs.void
put(K key, V value, long windowStartTimestamp)
Put a key-value pair into the window with given window start timestamp-
Methods inherited from interface org.apache.kafka.streams.state.ReadOnlyWindowStore
all, fetch
-
Methods inherited from interface org.apache.kafka.streams.processor.StateStore
close, flush, init, isOpen, name, persistent
-
-
-
-
Method Detail
-
put
@Deprecated void put(K key, V value)
Deprecated.as timestamp is not provided for the key-value pair, this causes inconsistency to identify the window frame to which the key belongs. Useput(Object, Object, long)
instead.Use the current record timestamp as thewindowStartTimestamp
and delegate toput(Object, Object, long)
.It's highly recommended to use
put(Object, Object, long)
instead, as the record timestamp is unlikely to be the correct windowStartTimestamp in general.- Parameters:
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 delete- Throws:
NullPointerException
- if the given key isnull
-
put
void put(K key, V value, long windowStartTimestamp)
Put a key-value pair into the window with given window start timestampIf serialized value bytes are null it is interpreted as delete. Note that deletes will be ignored in the case of an underlying store that retains duplicates.
- Parameters:
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 into- Throws:
NullPointerException
- if the given key isnull
-
fetch
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.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 callstore.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.
- Specified by:
fetch
in interfaceReadOnlyWindowStore<K,V>
- Parameters:
key
- the key to fetchtimeFrom
- time range start (inclusive)timeTo
- time range end (inclusive)- Returns:
- an iterator over key-value pairs
<timestamp, value>
- Throws:
InvalidStateStoreException
- if the store is not initializedNullPointerException
- if the given key isnull
-
fetch
default WindowStoreIterator<V> fetch(K key, Instant from, Instant to)
Description copied from interface:ReadOnlyWindowStore
Get all the key-value pairs with the given key and the time range from all the existing windows.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 callstore.fetch("A", Instant.ofEpochMilli(10), Instant.ofEpochMilli(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.
- Specified by:
fetch
in interfaceReadOnlyWindowStore<K,V>
- Parameters:
key
- the key to fetchfrom
- time range start (inclusive)to
- time range end (inclusive)- Returns:
- an iterator over key-value pairs
<timestamp, value>
-
fetch
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.This iterator must be closed after use.
- Specified by:
fetch
in interfaceReadOnlyWindowStore<K,V>
- Parameters:
from
- the first key in the rangeto
- the last key in the rangetimeFrom
- time range start (inclusive)timeTo
- time range end (inclusive)- Returns:
- an iterator over windowed key-value pairs
<Windowed<K>, value>
- Throws:
InvalidStateStoreException
- if the store is not initializedNullPointerException
- if one of the given keys isnull
-
fetch
default KeyValueIterator<Windowed<K>,V> fetch(K from, K to, Instant fromTime, Instant toTime)
Description copied from interface:ReadOnlyWindowStore
Get all the key-value pairs in the given key range and time range from all the existing windows.This iterator must be closed after use.
- Specified by:
fetch
in interfaceReadOnlyWindowStore<K,V>
- Parameters:
from
- the first key in the rangeto
- the last key in the rangefromTime
- time range start (inclusive)toTime
- time range end (inclusive)- Returns:
- an iterator over windowed key-value pairs
<Windowed<K>, value>
-
fetchAll
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.- Specified by:
fetchAll
in interfaceReadOnlyWindowStore<K,V>
- Parameters:
timeFrom
- the beginning of the time slot from which to search (inclusive)timeTo
- the end of the time slot from which to search (inclusive)- Returns:
- an iterator over windowed key-value pairs
<Windowed<K>, value>
- Throws:
InvalidStateStoreException
- if the store is not initialized
-
fetchAll
default KeyValueIterator<Windowed<K>,V> fetchAll(Instant from, Instant to)
Description copied from interface:ReadOnlyWindowStore
Gets all the key-value pairs that belong to the windows within in the given time range.- Specified by:
fetchAll
in interfaceReadOnlyWindowStore<K,V>
- Parameters:
from
- the beginning of the time slot from which to search (inclusive)to
- the end of the time slot from which to search (inclusive)- Returns:
- an iterator over windowed key-value pairs
<Windowed<K>, value>
-
-