今天我正在使用分区程序。它是hadoop定制分区程序中的基本程序。以下是我的分区代码片段。hadoop分区程序越来越不正确减少计数
公共类VowelConsPartitioner扩展分区程序{
@Override
public int getPartition(Text letterType, IntWritable count, int redCnt) {
// TODO Auto-generated method stub
//System.out.println("reduce cnt in partitioner: "+redCnt);
if(letterType.toString().equalsIgnoreCase("vowel")){
//System.out.println("vowel sound: "+1%redCnt);
return letterType.toString().hasCode()%redCnt;
}
if(letterType.toString().equalsIgnoreCase("consonent")){
//System.out.println("Cons sound: "+2%redCnt);
return letterType.toString().hasCode()%redCnt;
}
else
return 0;
}
}
我把我减速在我的司机这样的类....
job.setNumReduceTasks(3); job.setPartitionerClass(VowelConsPartitioner.class);
我想保留1个以上的减速器。但是我只能在一个reducer中获得o/p。此外,如果您看到分区代码,则第一个sysout(我已经评论过)将redCnt设为1.我不确定在我的驱动程序类中将其计数设置为3时发生了什么。有人可以帮我解决这个问题吗?
仅供参考...我正在制作罐子&在HDFS上运行。
所有,它的hashCode()。不是hasCode()我的不好!它的错字 –