How can you pass a small number of metadata collected in the Mapper to the Reducer? In my specific problem, I only want to pass two long values, so I wouldn't use MultipleOutputFormat or MultipleOutputs for these.
Some variants I have tried:
(1)
Mapper
context.getCounter("Countergroup", "Counter").increment(1);
Reducer
counter = context.getCounter("Countergroup", "Counter").getValue();
Counters are not updated regularly, so the function call in the Reducer results in a 0 value.
(2)
Mapper
context.getConfiguration().setInt("Counter", countTotal);
Reducer
counter = context.getConfiguration().getInt("Counter", 0);
Certainly Configurations can not be changed during a running job (was worth trying).
There have already been questions about this problem, but I could not find a working answer. Also, the API has changed. I am using Hadoop 0.20.2 .
Similar questions:
Passing values from Mapper to Reducer
Accessing a mapper's counter from a reducer (this looks promising, but it seems as if it does not work with the 0.20.2 API)