Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

I believe there are many use cases where List Serde could be useduseful.

Ex. https://stackoverflow.com/questions/41427174/aggregate-java-objects-in-a-list-with-kafka-streams-dsl-windowshttps://stackoverflow.com/questions/46365884/issue-with-arraylist-serde-in-kafka-streams-api 

...

This KIP proposes adding new ListSerializer and ListDeserializer classes as well as support for the new classes into ListSerde nested class inside the Serdes class. This will allow using List<T> Serde directly from Consumers, Producers and Streams.

...

List serde is an unusual type of serde because we need to consider two things here: the implementation of List interface(i.e. ArrayList, LinkedList, etc) and as well as enclosed elements' type.

First, as usually we need to specify our list serde using:

...

Then, we need to cover those two configurations and here I'm proposing these two four extra properties:

default.list.key/value.serde.type = java.util.ArrayList

...

Serialization Strategy

For the performance purposes the following serialization strategy was put in place. Depending on the type of an inner serde (a list's element type) the serialization will be performed in two different the following ways:

  1. If the an inner serde has one of the following serializers (LongSerializer.class, IntegerSerializer.class, ShortSerializer.class, FloatSerializer.class, DoubleSerializer.class), then the final payload will not contain each element's size encoded since the size of listed presented types is static (8 bytes, 4 bytes, 2 bytes, etc)
  2. If the inner serde doesn't have one of the serializers listed above, then a size of each element will be encoded in the final payload (see below)

...