Java – use MapReduce to find the average of numbers
•
Java
I've been trying to write some code to find the average of numbers using MapReduce
I try to use global counters to achieve my goal, but I can't set the counter value in my mapper's map method, and I can't retrieve the counter value in reducer's reduce method
Do I have to use global counters in the map (for example, by using the incrcounter (key, amount) of the reporter provided)? Or would you suggest any different logic to get the average of some numbers?
Solution
The logic is very simple:
Note that if the combiner class is set to the same class as the reducer, this logic will not work
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码