public void reduce(Text key, Iterator<ObjectWritable> values,
OutputCollector<Text, LinkDatum> output, Reporter reporter)
throws IOException {
List<LinkDatum> outlinkList = new ArrayList<LinkDatum>();
Node node = null;
// collect the outlinks while ignoring links with empty anchor text, also
// assign the node
while (values.hasNext()) {
ObjectWritable objWrite = values.next();
Object obj = objWrite.get();
if (obj instanceof LinkDatum) {
LinkDatum next = (LinkDatum)obj;
String anchor = next.getAnchor();
if (anchor != null) {
anchor = anchor.trim();
}
if (ignoreEmptyAnchors && (anchor == null || anchor.length() == 0)) {
continue;
}
outlinkList.add(next);
}
else if (obj instanceof Node) {
node = (Node)obj;
}
}
// has to have outlinks to index
if (node != null && outlinkList.size() > 0) {
String fromUrl = key.toString();
float outlinkScore = node.getInlinkScore();
for (LinkDatum datum : outlinkList) {
String toUrl = datum.getUrl();
datum.setUrl(fromUrl);
datum.setScore(outlinkScore);
datum.setLinkType(LinkDatum.INLINK);