Versions Compared

Key

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

...

  • New class org.apache.kafka.common.serialization.ListSerializer which implements the Serializer<List<T>> interface
  • New class org.apache.kafka.common.serialization.ListDeserializer which implements Deserializer<List<T>> interface
  • New subclass ListSerde<T> in org.apache.kafka.common.serialization.Serdes which creates new serde based on ListSerializer and ListDeserializer classes
  • New method public static <T> Serde<List<T>> ListSerde() in org.apache.kafka.common.serialization.Serdes class (infers list implementation and inner serde from config file)
  • New method public static <T> Serde<List<T>> ListSerde(Class listClass, Serde<T> innerSerde) in org.apache.kafka.common.serialization.Serdes class

...

Properties default.key/value.list.* will be ignored as long as default.key/value.serde is not set to org.apache.kafka.common.serialization.Serdes$ListSerde

Serialization Strategy

For 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 ways:

  1. If the inner serde has one of the following serializers (LongSerializer.classIntegerSerializer.classShortSerializer.classFloatSerializer.classDoubleSerializer.class), then the final payload will not contain each element's size since the size of listed 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)
                                                                        
                Case 1                             Case 2               
                                                                        
         +------------------+               +------------------+        
         |                  |               |                  |        
     Int |   Size of list   |           Int |   Size of list   |        
         |                  |               |                  |        
         |------------------|               |------------------|        
         |                  |               |                  |        
         |     Entry 1      |           Int |  Size of entry 1 |        
         |                  |               |                  |        
         |------------------|               |------------------|        
         |                  |               |                  |        
         |     Entry 2      |               |     Entry 1      |        
         |                  |               |                  |        
         |------------------|               |------------------|        
         |                  |               |                  |        
         |                  |           Int |  Size of entry 2 |        
         |                  |               |                  |        
         |                  |               |------------------|        
         |                  |               |                  |        
         |                  |               |     Entry 2      |        
         |       ...        |               |                  |        
         |                  |               |------------------|        
         |                  |               |                  |        
         |                  |               |                  |        
         |                  |               |       ...        |        
         |                  |               |                  |        
         |                  |               |                  |        
         +------------------+               +------------------+        


Compatibility, Deprecation, and Migration Plan

...