任何人都可以帮助我了解如何打印下面的减速器代码中使用的键和值
我尝试通过 Logger 和 System.out 打印出值,但我们无法在记录器和控制台中看到输出。
public static class IntSumReducer
extends Reducer<Text,IntWritable,Text,IntWritable> {
private IntWritable result = new IntWritable();
//private static final Log LOG = LogFactory.getLog(WordCount.class);
public void reduce(Text key, Iterable<IntWritable> values,
Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
//LOG.info("val = " + val.get());
//System.out.println("val = " + val.get());
}
//System.out.println("sum = " + sum + " key = " + key);
//LOG.info("sum = " + sum + " key = " + key);
result.set(sum);
context.write(key, result);
}
}