which reducer=(key.hashCode() & Integer.MAX_VALUE) % numReduceTasks,獲得當前的目的reducer。get
public static class NewPartitioner extends Partitioner<ReadPosBean, SAMRecordWritable>{
@Override
public int getPartition(ReadPosBean key, SAMRecordWritable value, int numPartitions) {
int n = key.getPos()/reduceInterval;
return n;
}
}
//設置partition
job.setPartitionerClass(NewPartitioner.class);
job.setNumReduceTasks(5);
我這裏分區爲5,reduce的個數也爲5.