Combiner - комбинер - пример Hadoop

public static class IntSumCombiner
extends Reducer<Text,IntWritable,Text,IntWritable> {
int max_sum = 0;
Text max_occured_key = new Text();

@Override
protected void cleanup(Context context) throws InterruptedException {
try{
context.write(new Text("----maximum of combiner===== "), new IntWritable(0));
context.write(max_occured_key, new IntWritable(max_sum));
context.write(new Text("-------------- "), new IntWritable(0));
}
catch(IOException e){
e.printStackTrace();
}
}
@Override
protected void setup(Context context) throws IOException,
InterruptedException{
try{
context.write(new Text("----combiner start-------"), new IntWritable(0));
}
catch(IOException e){
e.printStackTrace();
}
}

private IntWritable result = new IntWritable();

public void reduce(Text key, Iterable<IntWritable> values,
Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
if(sum > max_sum)
{
max_sum = sum;
//max_occured_key = key;
max_occured_key.set(key);
}

//context.write(max_occured_key, new IntWritable(max_sum));
result.set(sum);
// if (sum > 1) {
context.write(key, result);
//}
}
}