在map函数中,我想得到像hello world 1这样的结果
context.write(new Text(firstStr + "\t" + secondStr), new LongWritable(1));
在我的reduce函数中,
private LongWritable result = new LongWritable();
public void reduce(Text key, Iterable<LongWritable> values,Context context) throws IOException, InterruptedException {
long sum = 0;
for (LongWritable val : values) {
sum += val.get();
}
result.set(sum);
//context.write(new Text(key.toString().getBytes("GB18030")), result);
context.write(key, result);
}
在我的结果中,我发现我的r-00000部分的数据是这样的:
hello world
hello tom
thank you
事实上,我想要得到的结果如下
hello world 1
hello tom 1
我不知道发生了什么,请帮帮我?谢谢
暂无答案!
目前还没有任何答案,快来回答吧!