所以在我的代码中,我将数据分为三个部分,但在输出中,即使我将减速器的数量设置为 3,我也只能得到由第 0 个分区重新调整的输出
我的代码
public static class customPartitioner extends Partitioner<Text,Text>{
public int getPartition(Text key, Text value, int numReduceTasks){
String country = value.toString();
if(numReduceTasks==0)
return 0;
if(key.equals(new Text("key1")) && !value.equals(new Text("valuemy")))
return 1%numReduceTasks;
if(value.equals(new Text("valueother")) && key.equals(new Text("key1")) )
return 0;
else
return 2%numReduceTasks;
}
}
并将减速器的数量设置为
job.setNumReduceTasks(3);
它只给了我第 0 个分区的输出,即返回 0