TupleReducer countReducer = new TupleReducer<ITuple, NullWritable>() {
public void reduce(ITuple group, Iterable<ITuple> tuples, TupleMRContext context, Collector collector)
throws IOException, InterruptedException, TupleMRException {
int count = 0;
ITuple outputTuple = null;
for(ITuple tuple : tuples) {
count += (Integer) tuple.get("count");
outputTuple = tuple;
}
outputTuple.set("count", count);
collector.write(outputTuple, NullWritable.get());
}
};
job.setTupleCombiner(countReducer);
job.setTupleReducer(countReducer);