In the word count example reduce function is used for both as combiner and reducer.
public static class IntSumReducer extends Reducer<Text, IntWritable, Text,IntWritable> {
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
context.write(key, new IntWritable(sum));
}
}
I understood the way reducer works, but in the case of combiner, suppose my input is
<Java,1> <Virtual,1> <Machine,1> <Java,1>
It consider the first kv-pair and give the same output...!!?? since I've only one value. How come it considers both keys and make
<Java,1,1>
since we are considering one kv pair at a time? I know this a false assumption; someone please correct me on this please