counter: 1.1.0 - Only counts words (splitting is done separately now) counter-1.1.0
authorKai Moritz <kai@juplo.de>
Thu, 21 Oct 2021 19:49:51 +0000 (21:49 +0200)
committerKai Moritz <kai@juplo.de>
Thu, 21 Oct 2021 20:00:32 +0000 (22:00 +0200)
pom.xml
src/main/java/de/juplo/kafka/wordcount/counter/CounterApplicationProperties.java
src/main/java/de/juplo/kafka/wordcount/counter/CounterStreamProcessor.java

diff --git a/pom.xml b/pom.xml
index 898fc54..4fe2235 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
        </parent>
        <groupId>de.juplo.kafka.wordcount</groupId>
        <artifactId>counter</artifactId>
-       <version>1.0.1</version>
+       <version>1.1.0</version>
        <name>Wordcount-Counter</name>
        <description>Word-counting stream-processor of the multi-user wordcount-example</description>
        <properties>
index d670ba2..351ea18 100644 (file)
@@ -15,6 +15,6 @@ public class CounterApplicationProperties
 {
   private String bootstrapServer = "localhost:9092";
   private String applicationId = "counter";
-  private String inputTopic = "recordings";
+  private String inputTopic = "words";
   private String outputTopic = "countings";
 }
index e8d7c11..4d3bcc4 100644 (file)
@@ -16,10 +16,8 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import java.util.Arrays;
 import java.util.Properties;
 import java.util.concurrent.CompletableFuture;
-import java.util.regex.Pattern;
 
 import static org.apache.kafka.streams.errors.StreamsUncaughtExceptionHandler.StreamThreadExceptionResponse.SHUTDOWN_CLIENT;
 
@@ -28,8 +26,6 @@ import static org.apache.kafka.streams.errors.StreamsUncaughtExceptionHandler.St
 @Component
 public class CounterStreamProcessor
 {
-       final static Pattern PATTERN = Pattern.compile("\\W+");
-
        public final KafkaStreams streams;
 
 
@@ -42,7 +38,6 @@ public class CounterStreamProcessor
 
                KStream<String, String> source = builder.stream(properties.getInputTopic());
                source
-                               .flatMapValues(sentence -> Arrays.asList(PATTERN.split(sentence)))
                                .map((username, word) ->
                                {
                                        try