如何将Mapper中收集的少量元数据传递给Reducer?在我的具体问题中,我只想通过两个长的值,所以我不会使用MultipleOutputFormat或MultipleOutputs这些。
一些变体我曾尝试:将少量值从Mapper传递到Reducer
(1)
映射
context.getCounter("Countergroup", "Counter").increment(1);
减速
counter = context.getCounter("Countergroup", "Counter").getValue();
计数器不定时更新,所以Reducer中的函数调用将返回0值。
(2)
映射
context.getConfiguration().setInt("Counter", countTotal);
减速
counter = context.getConfiguration().getInt("Counter", 0);
当然配置不能运行作业期间改变(是值得一试)。
已经有关于这个问题的问题,但我找不到工作答案。此外,API已经改变。我正在使用Hadoop 0.20.2。
类似的问题:
Passing values from Mapper to Reducer
Accessing a mapper's counter from a reducer (这看起来很有希望,但它好像它不与0.20.2 API工作)
尝试动物园管理员。 –
这里不可能。 – DMolloy