Slide 16
Slide 16 text
Kafka Data Transformation
A B
KStreams App
Advanced message
transforms in Java
Source Topic Destination Topic
z
// Simple word count app using KStreams library //
val builder = new StreamsBuilder()
val textLines: KStream[String, String] =
builder.stream[String,
String]("streams-plaintext-input")
val wordCounts: KTable[String, Long] =
textLines.flatMapValues(
textLine => textLine.toLowerCase.split("\\W+"))
.groupBy((_, word) => word)
.count()
wordCounts.toStream.to("streams-wordcount-output")
val streams: KafkaStreams =
new KafkaStreams(builder.build(), config)
// Simple word count app using KStreams library //
val builder = new StreamsBuilder()
val textLines: KStream[String, String] =
builder.stream[String, String](" streams-plaintext-input")
val wordCounts: KTable[String, Long] =
textLines.flatMapValues(
textLine => textLine.toLowerCase.split("\\W+"))
.groupBy((_, word) => word)
.count()
wordCounts.toStream.to("streams-wordcount-output")
val streams: KafkaStreams =
new KafkaStreams(builder.build(), config)
// Simple word count app using KStreams library //
val builder = new StreamsBuilder()
val textLines: KStream[String, String] =
builder.stream[String,
String]("streams-plaintext-input")
val wordCounts: KTable[String, Long] =
textLines.flatMapValues(
textLine => textLine.toLowerCase.split("\\W+"))
.groupBy((_, word) => word)
.count()
wordCounts.toStream.to("streams-wordcount-output")
val streams: KafkaStreams =
new KafkaStreams(builder.build(), config)
// Simple word count app using KStreams library //
val builder = new StreamsBuilder()
val textLines: KStream[String, String] =
builder.stream[String,
String]("streams-plaintext-input")
val wordCounts: KTable[String, Long] =
textLines.flatMapValues(
textLine => textLine.toLowerCase.split("\\W+"))
.groupBy((_, word) => word)
.count()
wordCounts.toStream.to("streams-wordcount-output")
val streams: KafkaStreams =
new KafkaStreams(builder.build(), config)
// Simple word count app using KStreams library //
val builder = new StreamsBuilder()
val textLines: KStream[String, String] =
builder.stream[String,
String]("streams-plaintext-input")
val wordCounts: KTable[String, Long] =
textLines.flatMapValues(
textLine => textLine.toLowerCase.split("\\W+"))
.groupBy((_, word) => word)
.count()
wordCounts.toStream.to("streams-wordcount-output")
val streams: KafkaStreams =
new KafkaStreams(builder.build(), config)
// Simple word count app using KStreams library //
val builder = new StreamsBuilder()
val textLines: KStream[String, String] =
builder.stream[String,
String]("streams-plaintext-input")
val wordCounts: KTable[String, Long] =
textLines.flatMapValues(
textLine => textLine.toLowerCase.split("\\W+"))
.groupBy((_, word) => word)
.count()
wordCounts.toStream.to("streams-wordcount-output")
val streams: KafkaStreams =
new KafkaStreams(builder.build(), config)
// Simple word count app using KStreams library //
val builder = new StreamsBuilder()
val textLines: KStream[String, String] =
builder.stream[String,
String]("streams-plaintext-input")
val wordCounts: KTable[String, Long] =
textLines.flatMapValues(
textLine => textLine.toLowerCase.split("\\W+"))
.groupBy((_, word) => word)
.count()
wordCounts.toStream.to(" streams-wordcount-output")
val streams: KafkaStreams =
new KafkaStreams(builder.build(), config)