MAPREDUCE-3344. o.a.h.mapreduce.Reducer since 0.21 blindly casts to ReduceContext.ValueIterator. Contributed by Brock Noland.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1198910 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas White 2011-11-07 20:13:00 +00:00
parent a590b498ac
commit 9a6da7979e

View File

@ -26,6 +26,8 @@
import org.apache.hadoop.io.RawComparator;
import org.apache.hadoop.mapred.RawKeyValueIterator;
import java.util.Iterator;
/**
* Reduces a set of intermediate values which share a key to a smaller set of
* values.
@ -162,14 +164,15 @@ protected void cleanup(Context context
* {@link #run(org.apache.hadoop.mapreduce.Reducer.Context)} method to
* control how the reduce task works.
*/
@SuppressWarnings("unchecked")
public void run(Context context) throws IOException, InterruptedException {
setup(context);
while (context.nextKey()) {
reduce(context.getCurrentKey(), context.getValues(), context);
// If a back up store is used, reset it
((ReduceContext.ValueIterator)
(context.getValues().iterator())).resetBackupStore();
Iterator<VALUEIN> iter = context.getValues().iterator();
if(iter instanceof ReduceContext.ValueIterator) {
((ReduceContext.ValueIterator<VALUEIN>)iter).resetBackupStore();
}
}
cleanup(context);
}