-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReducer.java
More file actions
23 lines (18 loc) · 760 Bytes
/
Reducer.java
File metadata and controls
23 lines (18 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package Airline;
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.*;
public class AirlineReducer extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text t_key, Iterator<IntWritable> values, OutputCollector<Text,IntWritable> output, Reporter reporter) throws IOException {
Text key = t_key;
int frequencyForAirline = 0;
while (values.hasNext()) {
// replace type of value with the actual type of our value
IntWritable value = (IntWritable) values.next();
frequencyForAirline += value.get();
}
output.collect(key, new IntWritable(frequencyForAirline));
}
}