gpt4 book ai didi

hadoop - hadoop中未产生的输出

转载 作者:行者123 更新时间:2023-12-02 20:47:45 27 4
gpt4 key购买 nike

我正在尝试使用mapreduce查找每个小部件的平均值。使用hadoop fs -cat user / vagrant / example-1 / part-r-00000时,作业成功完成,但没有产生任何输出

    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());

}

最佳答案

我强烈建议您在mapper和reducer中都使用try / catch块,因此您可以知道是否是由于处理数据时引发了异常,请尝试将w.get()强制转换为float能够将该值(value)添加到总价中。

干杯。

关于hadoop - hadoop中未产生的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47230616/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com