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));
}
}
}
Mapreduce-finding the highest temperature mapper class