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