RawComparator comparator,
Class keyClass,
Class valueClass,
final KeyValueWriter output) throws IOException, InterruptedException {
Reducer reducer =
ReflectionUtils.newInstance(job.getReducerClass(), job);
// make output collector
OutputCollector collector =
new OutputCollector() {
public void collect(Object key, Object value)
throws IOException {
output.write(key, value);
}
};
// apply reduce function
try {
ReduceValuesIterator values =
new ReduceValuesIterator(
input, reporter, reduceInputValueCounter);
values.informReduceProgress();
while (values.more()) {
reduceInputKeyCounter.increment(1);
reducer.reduce(values.getKey(), values, collector, reporter);
values.informReduceProgress();
}
// Set progress to 1.0f if there was no exception,
reporter.setProgress(1.0f);
//Clean up: repeated in catch block below
reducer.close();
//End of clean up.
} catch (IOException ioe) {
try {
reducer.close();
} catch (IOException ignored) {
}
throw ioe;
}