首页 > 代码库 > 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));
}
}
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类
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。