mapreduce-查找最高气温的Mapper类
来源:互联网 发布:php 数值 偏移量 编辑:程序博客网 时间:2024/04/29 01:58
package com;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class MaxTemperatureMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
private static final int MISSING = 9999;
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException{
String line = value.toString();
String year = line.substring(15, 19);
int airTemperature;
if(line.charAt(87) == '+'){
airTemperature = Integer.parseInt(line.substring(88, 92));
}else{
airTemperature = Integer.parseInt(line.substring(87, 92));
}
String quality = line.substring(92, 93);
if(airTemperature != MISSING && quality.matches("[01459]")){
context.write(new Text(year), new IntWritable(airTemperature));
}
}
}
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class MaxTemperatureMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
private static final int MISSING = 9999;
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException{
String line = value.toString();
String year = line.substring(15, 19);
int airTemperature;
if(line.charAt(87) == '+'){
airTemperature = Integer.parseInt(line.substring(88, 92));
}else{
airTemperature = Integer.parseInt(line.substring(87, 92));
}
String quality = line.substring(92, 93);
if(airTemperature != MISSING && quality.matches("[01459]")){
context.write(new Text(year), new IntWritable(airTemperature));
}
}
}
0 0
- mapreduce-查找最高气温的Mapper类
- mapreduce-查找最高气温的Reducer类
- mapreduce-查找最高气温的Main类
- mapreduce实例,计算最高气温
- 权威指南MapReduce 最高气温计算
- Hadoop之Avro mapreduce最高气温程序
- MapReduce求年度最高气温值以及combiner的一点认识
- MapReduce求年度最高气温值以及combiner的一点认识
- 求每年最高气温
- hadoop2.x入门:编写mapreduce对气象数据集求每日最高气温和最低气温
- MapReduce之气温计算
- Hadoop中求最高气温
- python3爬取当天最高气温
- mapreduce中控制mapper的数量
- mapreduce中控制mapper的数量
- mapreduce中控制mapper的数量
- mapreduce中控制mapper的数量
- 应用程序通过对键中的气温进行排序来找出最高气温
- 在这里记录自己成长的点滴
- Java 理论与实践: 正确使用 Volatile 变量
- POJ-1753(c++)
- test
- ORA-01653: unable to extend table
- mapreduce-查找最高气温的Mapper类
- UVa 12325 - Zombie's Treasure Chest(暴力枚举+预处理)
- msf连接postgres数据库小问题
- Objective-C 学习笔记 12 - Block
- ORA-00020: maximum number of processes (150) exceeded
- 亲历印度人把t读成d
- Sicily 1198. Substring
- @autoreleasepool内存管理
- javascript用闭包保存状态