mapreduce-查找最高气温的Reducer类
2015-02-01 00:40
423 查看
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 = Integer.MIN_VALUE;
for(IntWritable value : values){
maxValue = 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 = Integer.MIN_VALUE;
for(IntWritable value : values){
maxValue = Math.max(maxValue, value.get());
}
context.write(key, new IntWritable(maxValue));
}
}
相关文章推荐
- mapreduce-查找最高气温的Mapper类
- mapreduce-查找最高气温的Main类
- MapReduce求年度最高气温值以及combiner的一点认识
- mapreduce实例,计算最高气温
- Hadoop之Avro mapreduce最高气温程序
- hadoop2.x入门:编写mapreduce对气象数据集求每日最高气温和最低气温
- 【大数据系列】MapReduce示例一年之内的最高气温
- MapReduce —案例(一)求最高分,最低分,平均分
- hadoop学习笔记-5-最高气温示例MaxTemperature
- MySQL 查找价格最高的图书经销商的几种SQL语句
- mapreduce剖析气象站平均气温
- mapreduce 查找共同好友
- Python之一个关于天气的csv文件中获取最高和最低气温的图表
- 查找字符串中出现频率最高的字符和次数
- 查找Linux中内存和CPU使用率最高的进程
- MySQL 查找价格最高的图书经销商的几种SQL语句
- MapReduce中Mapper类和Reducer类4函数解析
- uCOs 查找最高优先级任务的方法和我个人的见解
- Hadoop(十七)之MapReduce作业配置与Mapper和Reducer类
- mapreduce实战:统计美国各个气象站30年来的平均气温项目分析