浏览代码

Merge -r 1198909:1198910 from trunk to branch-0.23. Fixes: MAPREDUCE-3344.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1198914 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 13 年之前
父节点
当前提交
4f5fdb21cc

+ 3 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -31,6 +31,9 @@ Release 0.23.1 - Unreleased
     MAPREDUCE-3291. App fail to launch due to delegation token not 
     found in cache (Robert Evans via mahadev)
 
+    MAPREDUCE-3344. o.a.h.mapreduce.Reducer since 0.21 blindly casts to
+    ReduceContext.ValueIterator. (Brock Noland via tomwhite)
+
 Release 0.23.0 - 2011-11-01 
 
   INCOMPATIBLE CHANGES

+ 6 - 3
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Reducer.java

@@ -26,6 +26,8 @@ import org.apache.hadoop.conf.Configuration;
 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 @@ public class Reducer<KEYIN,VALUEIN,KEYOUT,VALUEOUT> {
    * {@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);
   }