public void reduce(IntWritable key, Iterator<PairOfFloatInt> values,
OutputCollector<PairOfInts, Text> output, Reporter reporter) throws IOException {
list.clear();
while (values.hasNext()) {
PairOfFloatInt p = values.next();
if (!list.add(new PairOfFloatInt(p.getLeftElement(), p.getRightElement()))) {
LOG.debug("Not added: " + p);
} else {
LOG.debug("Added: " + p);
}
reporter.incrCounter(Pairs.Total, 1);
}
LOG.debug(list.size());
int cntr = 0;
while (!list.isEmpty() && cntr < numResults) {
PairOfFloatInt pair = list.pollLast();
LOG.debug("output " + cntr + "=" + pair);
keyOut.set(pair.getRightElement(), key.get()); // first english docno, then foreign language
// docno
valOut.set(nf.format(pair.getLeftElement()));
output.collect(keyOut, valOut);
cntr++;
}
}