Created
May 3, 2017 07:57
-
-
Save enothereska/2edf31c38608be85a9b020256c475071 to your computer and use it in GitHub Desktop.
Querying a store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the window store named "queryStoreName" | |
ReadOnlyWindowStore<String, Long> windowStore = | |
streams.store("queryStoreName", QueryableStoreTypes.windowStore()); | |
// Fetch values for the key "europe" for all of the windows available in this application instance. | |
// To get *all* available windows we fetch windows from the beginning of time until now. | |
long timeFrom = 0; // beginning of time = oldest available | |
long timeTo = System.currentTimeMillis(); // now (in processing-time) | |
WindowStoreIterator<Long> iterator = windowStore.fetch("europe", timeFrom, timeTo); | |
while (iterator.hasNext()) { | |
KeyValue<Long, Long> next = iterator.next(); | |
long windowTimestamp = next.key; | |
System.out.println("Count of 'europe' @ time " + windowTimestamp + " is " + next.value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment