From f58f069e556e9782656cf4e1d09eabbfcd6fa1c4 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 16 Feb 2023 17:51:24 +0100 Subject: [PATCH] counter: 1.2.2. - Simplified topology - better readability --- pom.xml | 2 +- .../kafka/wordcount/counter/CounterStreamProcessor.java | 2 +- .../java/de/juplo/kafka/wordcount/counter/WordCount.java | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f57c829..15a07c1 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ de.juplo.kafka.wordcount counter - 1.2.1 + 1.2.2 Wordcount-Counter Word-counting stream-processor of the multi-user wordcount-example diff --git a/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java b/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java index bccb253..4cc0c68 100644 --- a/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java +++ b/src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java @@ -63,7 +63,7 @@ public class CounterStreamProcessor .noTypeInfo())) .count(Materialized.as(storeSupplier)) .toStream() - .map((word, count) -> new KeyValue<>(word, WordCount.of(word.getUser(), word.getWord(), count))) + .map((word, count) -> new KeyValue<>(word, WordCount.of(word, count))) .to( outputTopic, Produced.with( diff --git a/src/main/java/de/juplo/kafka/wordcount/counter/WordCount.java b/src/main/java/de/juplo/kafka/wordcount/counter/WordCount.java index 44ccb2d..0767dd1 100644 --- a/src/main/java/de/juplo/kafka/wordcount/counter/WordCount.java +++ b/src/main/java/de/juplo/kafka/wordcount/counter/WordCount.java @@ -9,4 +9,9 @@ public class WordCount String user; String word; long count; + + public static WordCount of(Word word, long count) + { + return new WordCount(word.getUser(), word.getWord(), count); + } } -- 2.20.1