nerdexam
Confluent

CCDAK · Question #129

What is an adequate topic configuration for the topic word-count-output? StreamsBuilder builder = new StreamsBuilder(); KStream<String, String> textLines = builder.stream("word-count-input")…

The correct answer is D. cleanup.policy=compact. Result is aggregated into a table with key as the unique word and value its frequency. We have to enable log compaction for this topic to align the topic's cleanup policy with KTable semantics.

Developing with Kafka Streams

Question

What is an adequate topic configuration for the topic word-count-output? StreamsBuilder builder = new StreamsBuilder(); KStream<String, String> textLines = builder.stream("word-count-input"); KTable<String, Long> wordCounts = textLines .mapValues(textLine -> textLine.toLowerCase()) .flatMapValues(textLine -> Arrays.asList(textLine.split("\W+"))) .selectKey((key, word) -> word) .groupByKey() .count(Materialized.as("Counts")); wordCounts.toStream().to("word-count-output", Produced.with(Serdes.String(), Serdes.Long())); builder.build();

Options

  • Amax.message.bytes=10000000
  • Bcleanup.policy=delete
  • Ccompression.type=lz4
  • Dcleanup.policy=compact

How the community answered

(29 responses)
  • A
    3% (1)
  • B
    10% (3)
  • C
    17% (5)
  • D
    69% (20)

Explanation

Result is aggregated into a table with key as the unique word and value its frequency. We have to enable log compaction for this topic to align the topic's cleanup policy with KTable semantics.

Topics

#cleanup.policy=compact#KTable changelog topic#topic configuration#log compaction

Community Discussion

No community discussion yet for this question.

Full CCDAK Practice