popular: 1.4.0 - Switched to Sliding Window
authorKai Moritz <kai@juplo.de>
Mon, 8 Jul 2024 06:57:26 +0000 (08:57 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 8 Jul 2024 07:11:27 +0000 (09:11 +0200)
src/main/java/de/juplo/kafka/wordcount/popular/PopularStreamProcessor.java

index 74aa2c6..367277b 100644 (file)
@@ -59,7 +59,7 @@ public class PopularStreamProcessor
                                .map((key, userWord) -> new KeyValue<>(Word.of(userWord.getWord()), Word.of(userWord.getWord())))
                                .peek((key, value) -> log.info("mapped: {} -> {}", key, value))
                                .groupByKey()
-                               .windowedBy(TimeWindows.ofSizeWithNoGrace(WINDOW_SIZE))
+                               .windowedBy(SlidingWindows.ofTimeDifferenceWithNoGrace(WINDOW_SIZE))
                                .count(
                                                Materialized
                                                                .<Word, Long>as(windowBytesStoreSupplier)