Grouped — Metadata for Aggregating Streams

Grouped provides the optional parameters that describe how to aggregate streams in the High-Level Stream Processing DSL:

  • Repartition topic name

  • Key Serde (Apache Kafka’s Serde for record keys)

  • Value Serde (Apache Kafka’s Serde for record values)

Grouped is used as an optional parameter in the following streaming aggregation operators:

A Grouped instance is created using one of the factory methods:

static <K, V> Grouped<K, V> as(final String name)
static <K> Grouped keySerde(final Serde<K> keySerde)
static <V> Grouped valueSerde(final Serde<V> valueSerde)
static <K, V> Grouped<K, V> with(
  final Serde<K> keySerde,
  final Serde<V> valueSerde)
static <K, V> Grouped<K, V> with(
  final String name,
  final Serde<K> keySerde,
  final Serde<V> valueSerde)

A Grouped instance can futher be configured using the "with" methods.

Table 1. Grouped’s "with" Methods
Method Description

withKeySerde

Grouped<K, V> withKeySerde(final Serde<K> keySerde)

withName

Grouped<K, V> withName(final String name)

withValueSerde

Grouped<K, V> withValueSerde(final Serde<V> valueSerde)

Scala API for Kafka Streams

Scala API for Kafka Streams makes the optional Grouped metadata an implicit parameter in the KStream and KTable APIs.

Moreover, ImplicitConversions object defines groupedFromSerde implicit conversion that creates a Grouped instance with the key and value Serde objects available in implicit scope.

And the last but not least, Scala API for Kafka Streams defines Grouped object with `with` factory methods that use implicit key and value Serde objects.

results matching ""

    No results matching ""