0% found this document useful (0 votes)
4 views1 page

Max Temperature Hadoop MapReduce Code

Uploaded by

lithinasus
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Max Temperature Hadoop MapReduce Code

Uploaded by

lithinasus
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Public class MaxTemperature {

// Mapper Class
Public static class TempMapper extends Mapper<Object, Text, Text, IntWritable> {
Private Text year = new Text();
Private IntWritable temperature = new IntWritable();
Public void map(Object key, Text value, Context context)
Throws IOException, InterruptedException {
String[] parts = [Link]().split(\\s+);
If ([Link] == 2) {
[Link](parts[0]);
[Link]([Link](parts[1]));
[Link](year, temperature); }} }
// Reducer Class
Public static class TempReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
Public void reduce(Text key, Iterable<IntWritable> values, Context context)
Throws IOException, InterruptedException {
Int maxTemp = Integer.MIN_VALUE;
For (IntWritable temp : values) {
maxTemp = [Link](maxTemp, [Link]()); }
[Link](key, new IntWritable(maxTemp)); } }
// Driver Code
Public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = [Link](conf, “Max Temperature per Year”);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link](job, new Path(args[0]));
[Link](job, new Path(args[1]));
[Link]([Link](true) ? 0 : 1); }}

You might also like