Hi Bhupesh,

You can take a look at com.datatorrent.lib.math.SumKeyVal operator where
StreamCodec is overridden on InputPort.
The new object of StreamCodec is constructed in getStreamCodec method. As
this is part of operator, you could set partition key to the StreamCodec.

Hope that helps.

Thanks,
Chinmay.


On Tue, Apr 26, 2016 at 4:18 PM, Bhupesh Chawda <bhup...@datatorrent.com>
wrote:

> Hi,
>
> I am trying to write a stream codec to set on the input port of an
> operator which is partitioned.
>
> The use case is to route incoming tuples to the operator partitions such
> that the tuple with the same key goes to the same partition.
>
> However, the tuple key fields are known only to the operator. Is there a
> way I can use this information to construct the StreamCodec such that the
> getPartition() method of the codec returns the hashcode of the tuple key
> field.
>
> If this is not possible, then is there a way I can have properties in the
> Stream codec and set them externally similar to operator properties?
>
> Thanks.
>
> ~Bhupesh
>

Reply via email to