-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMaxTempReducer.java
More file actions
42 lines (30 loc) · 1.14 KB
/
MaxTempReducer.java
File metadata and controls
42 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package hadoop;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import java.io.*;
import javax.servlet.*;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.RemoteIterator;
public class MaxTempReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
@Override
public void reduce(Text key, Iterable<IntWritable> values, Context context)
throws IOException, InterruptedException
{
int maxValue = findmax( values );
context.write(key, new IntWritable(maxValue));
}
private static int findmax(Iterable<IntWritable> values) {
int tmpValue = Integer.MIN_VALUE;
for( IntWritable value: values) {
tmpValue = Math.max(tmpValue ,value.get());
}
int maxValue = tmpValue;
return maxValue;
}
}