Package org.apache.kafka.streams.state
Interface ReadOnlyWindowStore<K,V>
-
- Type Parameters:
K- Type of keysV- Type of values
- All Known Subinterfaces:
WindowStore<K,V>
public interface ReadOnlyWindowStore<K,V>A window store that only supports read operations Implementations should be thread-safe as concurrent reads and writes are expected.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description KeyValueIterator<Windowed<K>,V>all()Gets all the key-value pairs in the existing windows.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>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.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.
-
-
-
Method Detail
-
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.
- Returns:
- an iterator over key-value pairs
<timestamp, value> - Throws:
InvalidStateStoreException- if the store is not initializedjava.lang.NullPointerException- If null is used for key.
-
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.- 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 initializedjava.lang.NullPointerException- If null is used for any key.
-
all
KeyValueIterator<Windowed<K>,V> all()
Gets all the key-value pairs in the existing windows.- Returns:
- an iterator over windowed key-value pairs
<Windowed<K>, value> - Throws:
InvalidStateStoreException- if the store is not initialized
-
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.- 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> - Throws:
InvalidStateStoreException- if the store is not initializedjava.lang.NullPointerException- if null is used for any key
-
-