gpt4 book ai didi

hadoop - 为什么 reducer 在 hadoop map/reduce 中有不同的输入/输出键、值?

转载 作者:可可西里 更新时间:2023-11-01 14:50:31 25 4
gpt4 key购买 nike

由于 Map/Reduce 应用程序的性质,reduce 函数可能被调用多次,因此输入/输出键值必须与 MongoDB 的 Map/Reduce 实现相同。我想知道为什么在 Hadoop 实现中它是不同的?(我最好说它是允许不同的)

org.apache.hadoop.mapreduce.Reducer<KEYIN,VALUEIN,KEYOUT,VALUEOUT>

第二个问题:hadoop如何知道reduce函数的输出应该返回到下次运行时再次reduce或者写入HDFS?例如:

public class MyReducer extends Reducer<Text, IntWritable, Text, IntWritable>
public void reduce(Text key, Iterable<IntWritable> values, Context context) {
context.write(key, value) /* this key/value will be returned to reduce in next run or will be written to HDFS? */
}
}

最佳答案

考虑示例,输入是文档名称(作为键)和文档行(值),结果是行长度的 STDDEV(标准差)。
概括地说——聚合类型不必与输入数据类型相匹配。所以 Hadoop 把自由留给了开发者。
对于你的第二个问题 - Hadoop 没有类似于 MongoDB 增量 MapReduce 的机制,因此 reducer 的结果总是保存到 HDFS(或其他 DFS)并且永远不会返回到 reduce。

关于hadoop - 为什么 reducer 在 hadoop map/reduce 中有不同的输入/输出键、值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13784904/

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