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
26
27
28
29
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 {
try {
Output system_id = iter.next();
FakeJoinWritable add = (FakeJoinWritable)system_id.get();
while (iter.hasNext()) {
CallsJoinWritable info_next = (CallsJoinWritable)iter.next().get();
Text res = new Text(info_next.toString() + add.system_id + ", " + add.red_id);
//System.out.println(system_id);
context.write(null, res);
}
} catch(Exception exc){
exc.printStackTrace();
}
}
}