From: Kai Moritz Date: Thu, 16 Feb 2023 16:51:24 +0000 (+0100) Subject: counter: 1.2.2. - Simplified topology - better readability X-Git-Tag: counter-1.2.2 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=f58f069e556e9782656cf4e1d09eabbfcd6fa1c4;p=demos%2Fkafka%2Fwordcount counter: 1.2.2. - Simplified topology - better readability --- 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); + } }