Author: ddas
Date: Wed May 27 02:31:34 2009
New Revision: 778972
URL: http://svn.apache.org/viewvc?rev=778972&view=rev
Log:
HADOOP-5816. Fixes a problem in the KeyFieldBasedComparator to do with
ArrayIndexOutOfBounds exception. Contributed by He Yongqiang.
Modified:
hadoop/core/branches/branch-0.19/CHANGES.txt
hadoop/core/branches/branch-0.19/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java
hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java
Modified: hadoop/core/branches/branch-0.19/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/CHANGES.txt?rev=778972&r1=778971&r2=778972&view=diff
==============================================================================
--- hadoop/core/branches/branch-0.19/CHANGES.txt (original)
+++ hadoop/core/branches/branch-0.19/CHANGES.txt Wed May 27 02:31:34 2009
@@ -114,6 +114,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.19.1 - 2009-02-23
HADOOP-5225. Workaround for tmp file handling in HDFS. sync() is
Modified:
hadoop/core/branches/branch-0.19/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java
URL:
http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java?rev=778972&r1=778971&r2=778972&view=diff
==============================================================================
---
hadoop/core/branches/branch-0.19/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java
(original)
+++
hadoop/core/branches/branch-0.19/src/mapred/org/apache/hadoop/mapred/lib/KeyFieldBasedComparator.java
Wed May 27 02:31:34 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.19/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java
URL:
http://svn.apache.org/viewvc/hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java?rev=778972&r1=778971&r2=778972&view=diff
==============================================================================
---
hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java
(original)
+++
hadoop/core/branches/branch-0.19/src/test/org/apache/hadoop/mapred/lib/TestKeyFieldBasedComparator.java
Wed May 27 02:31:34 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();
}
}