You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by dd...@apache.org on 2009/05/27 04:20:51 UTC

svn commit: r778964 - in /hadoop/core/branches/branch-0.20: ./ CHANGES.txt src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java

Author: ddas
Date: Wed May 27 02:20:51 2009
New Revision: 778964

URL: http://svn.apache.org/viewvc?rev=778964&view=rev
Log:
Merge -r 778961:778962 from trunk onto 0.20 branch. Fixes HADOOP-5816.

Modified:
    hadoop/core/branches/branch-0.20/   (props changed)
    hadoop/core/branches/branch-0.20/CHANGES.txt   (contents, props changed)
    hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java
    hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java

Propchange: hadoop/core/branches/branch-0.20/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 27 02:20:51 2009
@@ -1,2 +1,2 @@
 /hadoop/core/branches/branch-0.19:713112
-/hadoop/core/trunk:727001,727117,727191,727212,727217,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,736426,738328,738697,740077,740157,741703,741762,743745,743816,743892,744894,745180,746010,746206,746227,746233,746274,746338,746902-746903,746925,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752609,752834,752836,752913,752932,753112-753113,753346,754645,754847,754927,755035,755226,755348,755370,755418,755426,755790,755905,755938,755960,755986,755998,756352,757448,757624,757849,758156,758180,759398,759932,760502,760783,761046,761482,761632,762216,762879,763107,763502,764967,765016,765809,765951,771607,771661,772844,772876,772884,772920,773889,776638
+/hadoop/core/trunk:727001,727117,727191,727212,727217,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,736426,738328,738697,740077,740157,741703,741762,743745,743816,743892,744894,745180,746010,746206,746227,746233,746274,746338,746902-746903,746925,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752609,752834,752836,752913,752932,753112-753113,753346,754645,754847,754927,755035,755226,755348,755370,755418,755426,755790,755905,755938,755960,755986,755998,756352,757448,757624,757849,758156,758180,759398,759932,760502,760783,761046,761482,761632,762216,762879,763107,763502,764967,765016,765809,765951,771607,771661,772844,772876,772884,772920,773889,776638,778962

Modified: hadoop/core/branches/branch-0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/CHANGES.txt?rev=778964&r1=778963&r2=778964&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.20/CHANGES.txt Wed May 27 02:20:51 2009
@@ -86,6 +86,9 @@
     HADOOP-5728. Fixed FSEditLog.printStatistics IndexOutOfBoundsException.
     (Wang Xu via johan)    
 
+    HADOOP-5816. Fixes a problem in the KeyFieldBasedComparator to do with
+    ArrayIndexOutOfBounds exception. (He Yongqiang via ddas)
+
 Release 0.20.0 - 2009-04-15
 
   INCOMPATIBLE CHANGES

Propchange: hadoop/core/branches/branch-0.20/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May 27 02:20:51 2009
@@ -1,3 +1,3 @@
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
-/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,735082,736426,738602,738697,739416,740077,740157,741703,741762,743296,743745,743816,743892,744894,745180,745268,746010,746193,746206,746227,746233,746274,746902-746903,746925,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752514,752555,752590,752609,752834,752836,752913,752932,753112-753113,753346,754645,754847,754927,755035,755226,755348,755370,755418,755426,755790,755905,755938,755986,755998,756352,757448,757624,757849,758156,758180,759398,759932,760502,760783,761046,761482,761632,762216,762879,763107,763502,764967,765016,765809,765951,771607,772844,772876,772884,772920,773889,776638
+/hadoop/core/trunk/CHANGES.txt:727001,727117,727191,727212,727228,727255,727869,728187,729052,729987,732385,732572,732613,732777,732838,732869,733887,734870,734916,735082,736426,738602,738697,739416,740077,740157,741703,741762,743296,743745,743816,743892,744894,745180,745268,746010,746193,746206,746227,746233,746274,746902-746903,746925,746944,746968,746970,747279,747289,747802,748084,748090,748783,749262,749318,749863,750533,752073,752514,752555,752590,752609,752834,752836,752913,752932,753112-753113,753346,754645,754847,754927,755035,755226,755348,755370,755418,755426,755790,755905,755938,755986,755998,756352,757448,757624,757849,758156,758180,759398,759932,760502,760783,761046,761482,761632,762216,762879,763107,763502,764967,765016,765809,765951,771607,772844,772876,772884,772920,773889,776638,778962

Modified: hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java?rev=778964&r1=778963&r2=778964&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java (original)
+++ hadoop/core/branches/branch-0.20/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java Wed May 27 02:20:51 2009
@@ -106,7 +106,7 @@
     }
     int compareResult = 0;
     if (!key.numeric) {
-      compareResult = compareBytes(first, start1, end1, second, start2, end2);
+      compareResult = compareBytes(first, start1, end1-start1+1, second, start2, end2-start2+1);
     }
     if (key.numeric) {
       compareResult = numericalCompare (first, start1, end1, second, start2, end2);

Modified: hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java
URL: http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java?rev=778964&r1=778963&r2=778964&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java (original)
+++ hadoop/core/branches/branch-0.20/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java Wed May 27 02:20:51 2009
@@ -38,12 +38,16 @@
 
 public class TestKeyFieldBasedComparator extends HadoopTestCase {
   JobConf conf;
-  String line1 = "123 -123 005120 123.9 0.01 0.18 010 10.1 4444 011 011 234";
-  String line2 = "134 -12 005100 123.10 -1.01 0.19 02 10.0 4444.1";
+  JobConf localConf;
+  
+  String line1 = "123 -123 005120 123.9 0.01 0.18 010 10.0 4444.1 011 011 234";
+  String line2 = "134 -12 005100 123.10 -1.01 0.19 02 10.1 4444";
 
   public TestKeyFieldBasedComparator() throws IOException {
     super(HadoopTestCase.LOCAL_MR, HadoopTestCase.LOCAL_FS, 1, 1);
     conf = createJobConf();
+    localConf = createJobConf();
+    localConf.set("map.output.key.field.separator", " ");
   }
   public void configure(String keySpec, int expect) throws Exception {
     Path testdir = new Path("build/test/test.mapred.spill");
@@ -123,9 +127,24 @@
     configure("-k2.4,2.4n", 2);
     configure("-k7,7", 1);
     configure("-k7,7n", 2);
-    configure("-k8,8n", 2);
-    configure("-k9,9n", 1);
+    configure("-k8,8n", 1);
+    configure("-k9,9", 2);
     configure("-k11,11",2);
     configure("-k10,10",2);
+    
+    localTestWithoutMRJob("-k9,9", 1);
+  }
+  
+  byte[] line1_bytes = line1.getBytes();
+  byte[] line2_bytes = line2.getBytes();
+
+  public void localTestWithoutMRJob(String keySpec, int expect) throws Exception {
+    KeyFieldBasedComparator<Void, Void> keyFieldCmp = new KeyFieldBasedComparator<Void, Void>();
+    localConf.setKeyFieldComparatorOptions(keySpec);
+    keyFieldCmp.configure(localConf);
+    int result = keyFieldCmp.compare(line1_bytes, 0, line1_bytes.length,
+        line2_bytes, 0, line2_bytes.length);
+    if ((expect >= 0 && result < 0) || (expect < 0 && result >= 0))
+      fail();
   }
 }