You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@apex.apache.org by "Raja.Aravapalli" <Ra...@target.com> on 2016/07/07 20:20:41 UTC

hashing

Hi,

I have an operator, which is running in 3 instances I.e partionsā€¦ And, I want all the records with same key, here my key is "String" type, to be transferred to same instance/partition.

But, I am unable to achieve this with my below codec.



import com.datatorrent.lib.codec.KryoSerializableStreamCodec;

public class MyCodec extends KryoSerializableStreamCodec<String> {

    @Override
    public int getPartition(String tuple) {

        String[] toSplit = tuple.split("\\^");
        String exId = toSplit[1];

        return exId.hashCode();

    }

}


Any guidance pleaseā€¦


Thanks a lot.


Regards,
Raja.