StreamCodec

Let us now discuss a couple of concepts that were briefly introduced in the earlier section: StreamCodec and Unifier. A StreamCodec is a simple interface with three methods:

Object fromByteArray(Slice fragment); 
Slice toByteArray(T o); 
int getPartition(T o); 

Here, a Slice is just a byte array with an associated offset and length indicating the valid part of the array. The first two methods allow the user to provide custom serialization and deserialization code for tuples and the last is used as the first step of the three-step process described above to compute the set of downstream partitions that should receive a tuple. An object implementing this interface should be set as the value of the STREAM_CODEC attribute on the input ...

Get Learning Apache Apex now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.