首页 > 代码库 > mapreduce-查找最高气温的Reducer类

mapreduce-查找最高气温的Reducer类

package com;


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 maxValue = http://www.mamicode.com/Integer.MIN_VALUE;
for(IntWritable value : values){
maxValue = http://www.mamicode.com/Math.max(maxValue, value.get());
}
context.write(key, new IntWritable(maxValue));
}

}

mapreduce-查找最高气温的Reducer类