代码比之前的例子简单很多,仅仅是往一个named output "result" 写出结果。
MapReduce 编程 系列八 根据输入路径产生输出路径和清除HDFS目录(二)
xt) throws IOException, InterruptedException {
System.out.println("enter LogReducer:::cleanup method");
outputs.close();
}
public void reduce(Text key, Iterable
values, Context context) throws IOException, InterruptedException { System.out.println("enter LogReducer::reduce method"); int sum = 0; for (IntWritable val : values) { sum += val.get(); } System.out.println("key: " + key.toString() + " sum: " + sum); outputs.write("result", key, sum); } }
代码比之前的例子简单很多,仅仅是往一个named output "result" 写出结果。
代码比之前的例子简单很多,仅仅是往一个named output "result" 写出结果。