gpt4 book ai didi

hadoop - 为什么Reducer.class 不能在Hadoop MapReduce 中用作真正的reducer?

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

我注意到 Mapper.class 可以用作阶段中的真正映射器,以及用户定义的 reducer 。例如,

Phase 1:
Mapper.class -> WordCountReduce.class

这将起作用。
但是,Reducer.class 不能以相同的方式使用。即类似
Phase 2:
WordReadMap.class -> Reducer.class

不管用。

这是为什么?

最佳答案

我不明白为什么只要输出与输入属于同一类,它就不会。 default in the new API只是写出你传递给它的任何东西,它被实现为

@SuppressWarnings("unchecked")
protected void reduce(KEYIN key, Iterable<VALUEIN> values, Context context
) throws IOException, InterruptedException {
for(VALUEIN value: values) {
context.write((KEYOUT) key, (VALUEOUT) value);
}
}

对于旧 API,它是 interface ,并且不能直接实例化接口(interface)。如果您正在使用它,那么这就是它失败的原因。再说一次, Mapper也是一个接口(interface),你不应该实例化它......

关于hadoop - 为什么Reducer.class 不能在Hadoop MapReduce 中用作真正的reducer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13163463/

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