Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-12943

Bug in Kafka Streams Documentation (Aggregating)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.3.0
    • documentation, streams
    • None

    Description

      In the doc, for aggregating function, the example is incorrect

      https://kafka.apache.org/documentation/streams/developer-guide/dsl-api.html#aggregating

      It says

      KTable<byte[], Long> aggregatedStream = groupedStream.aggregate(
          () -> 0L, /* initializer */
          (aggKey, newValue, aggValue) -> aggValue + newValue.length(), /* adder */
          Materialized.as("aggregated-stream-store") /* state store name */
              .withValueSerde(Serdes.Long()); /* serde for aggregate value */

      Generic types are missing. Instead, it should be 

      KTable<byte[], Long> aggregatedStream = groupedStream.aggregate(
          () -> 0L, /* initializer */
          (aggKey, newValue, aggValue) -> aggValue + newValue.length(), /* adder */
          Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as("aggregated-stream-store") /* state store name */
              .withValueSerde(Serdes.Long()); /* serde for aggregate value */ 

      Otherwise, code won't work. I myself verified it. 

      Reference

      https://stackoverflow.com/questions/51040555/the-method-withvalueserde-in-the-type-materialized-is-not-applicable/51049472

      Attachments

        Issue Links

          Activity

            People

              marcolotz Marco Lotz
              rajeshksv37 Rajesh KSV
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: