I'm trying to modify an existing code, i managed to print key(grouped) and value (count of occurrences) but i need extract only one key which has the max value (count of occurrences). I'm not a java expert, so kindly excuse me for not explaining the question properly.
current output:
994290 5
994380 33
994410 1
994440 11
995010 2
995030 5
Expected:
994380 33
code
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
public class MaxTemperatureReducer
extends Reducer<Text, IntWritable, Text, IntWritable> {
@Override
public void reduce(Text key, Iterable<IntWritable> values,
Context context)
throws IOException, InterruptedException {
int count = 0;
for (IntWritable value : values) {
if(value.get() == 9999)
count++;
}
context.write(key, new IntWritable(count));
}
}