0
我正在嘗試使用mapreduce查找每個小部件的平均值。該作業被成功完成,但使用Hadoop FS -cat用戶/流浪/示例-1 /部分-R-00000輸出不是在hadoop中產生的
public static class MaxWidgetReducer
extends Reducer<Text, FloatWritable, FloatWritable, NullWritable> {
public void reduce(Text k, Iterable<FloatWritable> vals, Context context)
throws IOException, InterruptedException {
Float totalPrice = 0.0f;
Float avgPrice = 0.0f;
Integer count = null;
for (FloatWritable w : vals) {
totalPrice = (totalPrice + w.get());
count++;
}
avgPrice = (totalPrice)/(count);
context.write(new FloatWritable(avgPrice), NullWritable.get());
}