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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.