package mobvista.dmp.common;

import org.apache.hadoop.io.MD5Hash;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * author: houying
 * date  : 16-10-24
 * desc  :
 */
public class CommonPartitioner extends Partitioner<Text, Text> {
    @Override
    public int getPartition(Text text, Text text2, int numPartitions) {
        return ((MD5Hash.digest(text.toString()).quarterDigest() % numPartitions) + numPartitions) % numPartitions;
    }
}
