Browse Source

MAPREDUCE-5190. Unnecessary condition test in RandomSampler. Contributed by Jingguo Yao.

Harsh J 10 years ago
parent
commit
1d5c796d65

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

@@ -256,6 +256,9 @@ Release 2.8.0 - UNRELEASED
 
   IMPROVEMENTS
 
+    MAPREDUCE-5190. Unnecessary condition test in RandomSampler.
+    (Jingguo Yao via harsh)
+
     MAPREDUCE-6239. Consolidate TestJobConf classes in
     hadoop-mapreduce-client-jobclient and hadoop-mapreduce-client-core
     (Varun Saxena via harsh)

+ 2 - 4
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/lib/partition/InputSampler.java

@@ -230,10 +230,8 @@ public class InputSampler<K,V> extends Configured implements Tool  {
               // to reflect the possibility of existing elements being
               // pushed out
               int ind = r.nextInt(numSamples);
-              if (ind != numSamples) {
-                samples.set(ind, ReflectionUtils.copy(job.getConfiguration(),
-                                 reader.getCurrentKey(), null));
-              }
+              samples.set(ind, ReflectionUtils.copy(job.getConfiguration(),
+                               reader.getCurrentKey(), null));
               freq *= (numSamples - 1) / (double) numSamples;
             }
           }