You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ch...@apache.org on 2014/11/07 22:54:12 UTC
svn commit: r1637464 - in /pig/branches/branch-0.14: CHANGES.txt
src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java
test/org/apache/pig/test/TestEvalPipelineLocal.java
Author: cheolsoo
Date: Fri Nov 7 21:54:11 2014
New Revision: 1637464
URL: http://svn.apache.org/r1637464
Log:
PIG-4298: Descending order-by is broken in some cases when key is bytearrays (cheolsoo)
Modified:
pig/branches/branch-0.14/CHANGES.txt
pig/branches/branch-0.14/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java
pig/branches/branch-0.14/test/org/apache/pig/test/TestEvalPipelineLocal.java
Modified: pig/branches/branch-0.14/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.14/CHANGES.txt?rev=1637464&r1=1637463&r2=1637464&view=diff
==============================================================================
--- pig/branches/branch-0.14/CHANGES.txt (original)
+++ pig/branches/branch-0.14/CHANGES.txt Fri Nov 7 21:54:11 2014
@@ -101,6 +101,8 @@ OPTIMIZATIONS
BUG FIXES
+PIG-4298: Descending order-by is broken in some cases when key is bytearrays (cheolsoo)
+
PIG-4263: Move tez local mode unit tests to a separate target (daijy)
PIG-4257: Fix several e2e tests on secure cluster (daijy)
Modified: pig/branches/branch-0.14/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.14/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java?rev=1637464&r1=1637463&r2=1637464&view=diff
==============================================================================
--- pig/branches/branch-0.14/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java (original)
+++ pig/branches/branch-0.14/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java Fri Nov 7 21:54:11 2014
@@ -122,8 +122,10 @@ public class PigBytesRawComparator exten
if( dataByteArraysCompare ) {
rc = WritableComparator.compareBytes(b1, offset1, length1, b2, offset2, length2);
} else {
- // Subtract 2, one for null byte and one for index byte
- rc = mWrappedComp.compare(b1, s1 + 1, l1 - 2, b2, s2 + 1, l2 - 2);
+ // Subtract 2, one for null byte and one for index byte. Also, do not reverse the sign
+ // of rc when mAsc[0] is false because BinInterSedesTupleRawComparator.compare() already
+ // takes that into account.
+ return mWrappedComp.compare(b1, s1 + 1, l1 - 2, b2, s2 + 1, l2 - 2);
}
} else {
// For sorting purposes two nulls are equal.
Modified: pig/branches/branch-0.14/test/org/apache/pig/test/TestEvalPipelineLocal.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.14/test/org/apache/pig/test/TestEvalPipelineLocal.java?rev=1637464&r1=1637463&r2=1637464&view=diff
==============================================================================
--- pig/branches/branch-0.14/test/org/apache/pig/test/TestEvalPipelineLocal.java (original)
+++ pig/branches/branch-0.14/test/org/apache/pig/test/TestEvalPipelineLocal.java Fri Nov 7 21:54:11 2014
@@ -1231,4 +1231,30 @@ public class TestEvalPipelineLocal {
Iterator<Tuple> iter = pigServer.openIterator("D");
Assert.assertEquals(iter.next().toString(), "(lily)");
}
+
+ public static class TOTUPLENOINNERSCHEMA extends EvalFunc<Tuple> {
+ @Override
+ public Tuple exec(Tuple input) throws IOException {
+ return input;
+ }
+ }
+
+ // see PIG-4298
+ @Test
+ public void testBytesRawComparatorDesc() throws Exception{
+ File f1 = createFile(new String[]{"2", "1", "4", "3"});
+
+ pigServer.registerQuery("a = load '" + Util.generateURI(f1.toString(), pigServer.getPigContext())
+ + "' as (value:long);");
+ pigServer.registerQuery("b = foreach a generate " + TOTUPLENOINNERSCHEMA.class.getName() + "(value);");
+ pigServer.registerQuery("c = foreach b generate flatten($0);");
+ pigServer.registerQuery("d = order c by $0 desc;");
+
+ Iterator<Tuple> iter = pigServer.openIterator("d");
+ Assert.assertEquals(iter.next().toString(), "(4)");
+ Assert.assertEquals(iter.next().toString(), "(3)");
+ Assert.assertEquals(iter.next().toString(), "(2)");
+ Assert.assertEquals(iter.next().toString(), "(1)");
+ Assert.assertFalse(iter.hasNext());
+ }
}