private static class MergeReducer extends MapReduceBase implements
Reducer<IntWritable, HITSNode, IntWritable, HITSNode> {
public void reduce(IntWritable key, Iterator<HITSNode> values,
OutputCollector<IntWritable, HITSNode> output, Reporter reporter)
throws IOException {
ArrayListOfIntsWritable adjList = new ArrayListOfIntsWritable();
//construct new HITSNode
HITSNode nodeOut = new HITSNode();
nodeOut.setType(HITSNode.TYPE_NODE_COMPLETE);
nodeOut.setARank(0);
nodeOut.setInlinks(new ArrayListOfIntsWritable());
nodeOut.setHRank(0);
nodeOut.setOutlinks(new ArrayListOfIntsWritable());
nodeOut.setNodeId(key.get());
while (values.hasNext()) {
HITSNode nodeIn = values.next();
if (nodeIn.getType() == HITSNode.TYPE_HUB_COMPLETE)
{
nodeOut.setHRank(nodeIn.getHRank());
nodeOut.setOutlinks(new ArrayListOfIntsWritable(nodeIn.getOutlinks()));
}
if (nodeIn.getType() == HITSNode.TYPE_AUTH_COMPLETE)
{
nodeOut.setARank(nodeIn.getARank());
nodeOut.setInlinks(new ArrayListOfIntsWritable(nodeIn.getInlinks()));
}
}
output.collect(key, nodeOut);
}