package lab3 import org apache hadoop mapreduce import org apache hado

 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
package lab3;
import org.apache.hadoop.mapreduce.*;
import org.apache.hadoop.mapreduce.Reducer.Context;
import org.apache.hadoop.io.*;
import java.io.*;
import java.util.Iterator;
import java.io.IOException;
import java.util.Iterator;
public class JoinByKeyReducer extends Reducer<JoinByKeyComparable, Text, NullWritable, Text> {
@Override
protected void reduce(JoinByKeyComparable key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
Iterator<Text> itr = values.iterator();
Text system_id = new Text (itr.next());
Text reg_id = new Text (itr.next());
while (itr.hasNext()){
Text info_next= itr.next();
Text out = new Text(info_next.toString()+", " + system_id+", " + reg_id);
context.write(null, out);
}
}
}