Status
Current state: Under Discussion
Discussion thread: here
JIRA: KAFKA-4499
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
Currently, both KTable and windowed-KTable stores can be queried via IQ feature. While ReadOnlyKeyValueStore(for KTable stores) provide method all() to scan the whole store (ie, returns an iterator over all stored key-value pairs), there is no similar API for ReadOnlyWindowStore (for windowed-KTable stores).
This limits the usage of a windowed store, because the user needs to know what keys are stored in order the query it.
Public Interfaces
Methods similar to the ones found in ReadOnlyKeyValueStore
will be introduced into the ReadOnlyWindowStore
interface. They are the following:
/**
- Gets the latest window for each distinctive key.
- @returns an iterator over windowed key-value pairs
Unknown macro: {@code <Windowed<K>, value>}
- @throws InvalidStateStoreException if the store is not initialized
- @throws NullPointerException if null is used for any key
*/
Collection<Windowed<K>> range(long timeFrom, long timeTo);
/** - Returns the minimum key in existing windows.
- @returns a
Unknown macro: {@code Windowed<K>}value
value
- @throws InvalidStateStoreException if the store is not initialized
- @throws NullPointerException if null is used for any key
*/
Windowed<K> minKey();
/**
- Returns the maximum key in existing windows
- @returns a
- @throws InvalidStateStoreException if the store is not initialized
- @throws NullPointerException if null is used for any key
*/
Windowed<K> maxKey();
Proposed Changes
With the need to test the implementation of these methods in mind, the ReadOnlyWindowStoreStub
class will implement these additions (i.e. @Override public Collection<Windowed<K>> range(long timeFrom, long timeTo){...}
). The corresponding test will also be modified. (e.g. @Test public void testRange(){...
})
Following the changes in ReadOnlyWindowStore
, CachingWindowStore
and other WindowStore
API will implement these changes accordingly.
Compatibility, Deprecation, and Migration Plan