CCDAK · Question #17
Which of the following Kafka Streams operators are stateful? (select all that apply)
The correct answer is B. reduce C. joining D. count F. aggregate. Stateful operators in Kafka Streams are those that maintain a state store to track information across multiple records over time. reduce (B) and aggregate (F) both accumulate values across a keyed stream into a running result held in a state store - aggregate is the more…
Question
Which of the following Kafka Streams operators are stateful? (select all that apply)
Options
- Aflatmap
- Breduce
- Cjoining
- Dcount
- Epeek
- Faggregate
How the community answered
(20 responses)- A10% (2)
- B75% (15)
- E15% (3)
Explanation
Stateful operators in Kafka Streams are those that maintain a state store to track information across multiple records over time. reduce (B) and aggregate (F) both accumulate values across a keyed stream into a running result held in a state store - aggregate is the more general form (supports type changes), while reduce requires the same input/output type. count (D) is essentially a specialized aggregate that increments a running tally per key, and joining (C) requires buffering records from one or both sides of the join in state stores to match keys across time windows.
The distractors are stateless: flatMap (A) transforms each record independently into zero or more output records with no memory of prior records, and peek (E) is a pass-through that performs a side-effect (e.g., logging) on each record without storing anything.
Memory tip: Ask yourself - "Does this operator need to remember something from a previous record to do its job?" If yes, it's stateful. Count needs to remember the previous count; join needs to remember unmatched records; reduce/aggregate need the running accumulator. FlatMap and peek only look at the current record and move on.
Topics
Community Discussion
No community discussion yet for this question.