pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1401926 - in /pig/trunk: CHANGES.txt src/org/apache/pig/data/BinInterSedes.java src/org/apache/pig/data/DataByteArray.java test/org/apache/pig/test/TestDataModel.java
Date Thu, 25 Oct 2012 00:11:30 GMT
Author: gdfm
Date: Thu Oct 25 00:11:29 2012
New Revision: 1401926

URL: http://svn.apache.org/viewvc?rev=1401926&view=rev
Log:
PIG-2999: Regression after PIG-2975: BinInterSedesTupleRawComparator secondary sort failing
(cheolsoo via azaroth)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/data/BinInterSedes.java
    pig/trunk/src/org/apache/pig/data/DataByteArray.java
    pig/trunk/test/org/apache/pig/test/TestDataModel.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1401926&r1=1401925&r2=1401926&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Thu Oct 25 00:11:29 2012
@@ -330,6 +330,8 @@ OPTIMIZATIONS
 
 BUG FIXES
 
+PIG-2999: Regression after PIG-2975: BinInterSedesTupleRawComparator secondary sort failing
(cheolsoo via azaroth)
+
 PIG-2998: Fix TestScriptLanguage and TestMacroExpansion (cheolsoo via jcoveney)
 
 PIG-2975: TestTypedMap.testOrderBy failing with incorrect result (knoguchi via jcoveney)

Modified: pig/trunk/src/org/apache/pig/data/BinInterSedes.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/data/BinInterSedes.java?rev=1401926&r1=1401925&r2=1401926&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/data/BinInterSedes.java (original)
+++ pig/trunk/src/org/apache/pig/data/BinInterSedes.java Thu Oct 25 00:11:29 2012
@@ -862,9 +862,11 @@ public class BinInterSedes implements In
                 if (type1 == type2) {
                     int basz1 = readSize(bb1, dt1);
                     int basz2 = readSize(bb2, dt2);
-                    rc = org.apache.hadoop.io.WritableComparator.compareBytes(
+                    rc = WritableComparator.compareBytes(
                           bb1.array(), bb1.position(), basz1,
                           bb2.array(), bb2.position(), basz2);
+                    bb1.position(bb1.position() + basz1);
+                    bb2.position(bb2.position() + basz2);
                 }
                 break;
             }

Modified: pig/trunk/src/org/apache/pig/data/DataByteArray.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/data/DataByteArray.java?rev=1401926&r1=1401925&r2=1401926&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/data/DataByteArray.java (original)
+++ pig/trunk/src/org/apache/pig/data/DataByteArray.java Thu Oct 25 00:11:29 2012
@@ -21,6 +21,8 @@ import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
 import java.util.Arrays;
 
+import org.apache.hadoop.io.WritableComparator;
+
 import org.apache.pig.classification.InterfaceAudience;
 import org.apache.pig.classification.InterfaceStability;
 
@@ -207,20 +209,8 @@ public class DataByteArray implements Co
     }
 
     public static int compare(byte[] b1, byte[] b2) {
-        int i;
-        for (i = 0; i < b1.length; i++) {
-            // If the other has run out of characters, we're bigger.
-            if (i >= b2.length)
-                return 1;
-            if (b1[i] < b2[i])
-                return -1;
-            else if (b1[i] > b2[i])
-                return 1;
-        }
-        // If the other still has characters left, it's greater
-        if (i < b2.length)
-            return -1;
-        return 0;
+        return WritableComparator.compareBytes(b1, 0, b1.length,
+                                               b2, 0, b2.length);
     }
 
     @Override

Modified: pig/trunk/test/org/apache/pig/test/TestDataModel.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestDataModel.java?rev=1401926&r1=1401925&r2=1401926&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestDataModel.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestDataModel.java Thu Oct 25 00:11:29 2012
@@ -337,19 +337,19 @@ public class TestDataModel extends junit
 
         t2 = tf.newTuple();
         t2.append(new Integer(2));
-        assertEquals("greater than tuple with lesser value", 1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 < t1.compareTo(t2));
 
         t2 = tf.newTuple();
         t2.append(new Integer(4));
-        assertEquals("less than tuple with greater value", -1, t1.compareTo(t2));
+        assertTrue("less than tuple with greater value", 0 > t1.compareTo(t2));
 
         t2 = tf.newTuple();
         t2.append(new Integer(3));
         t2.append(new Integer(4));
-        assertEquals("less than bigger tuple", -1, t1.compareTo(t2));
+        assertTrue("less than bigger tuple", 0 > t1.compareTo(t2));
 
         t2 = tf.newTuple();
-        assertEquals("greater than smaller tuple", 1, t1.compareTo(t2));
+        assertTrue("greater than smaller tuple", 0 < t1.compareTo(t2));
     }
 
     @Test
@@ -369,48 +369,48 @@ public class TestDataModel extends junit
         t2 = tf.newTuple();
         t2.append(new DataByteArray("aaa"));
         t2.append(new DataByteArray("aaa"));
-        assertEquals("greater than tuple with lesser value", 1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 < t1.compareTo(t2));
 
         t2 = tf.newTuple();
         t2.append(new DataByteArray("ddd"));
         t2.append(new DataByteArray("ddd"));
-        assertEquals("less than tuple with greater value", -1, t1.compareTo(t2));
+        assertTrue("less than tuple with greater value", 0 > t1.compareTo(t2));
 
         // First column same, second lesser
         t2 = tf.newTuple();
         t2.append(new DataByteArray("bbb"));
         t2.append(new DataByteArray("aaa"));
-        assertEquals("greater than tuple with lesser value", 1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 < t1.compareTo(t2));
 
         // First column same, second greater
         t2 = tf.newTuple();
         t2.append(new DataByteArray("bbb"));
         t2.append(new DataByteArray("ccc"));
-        assertEquals("greater than tuple with lesser value", -1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 > t1.compareTo(t2));
 
         // First column less, second same
         t2 = tf.newTuple();
         t2.append(new DataByteArray("aaa"));
         t2.append(new DataByteArray("bbb"));
-        assertEquals("greater than tuple with lesser value", 1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 < t1.compareTo(t2));
 
         // First column greater, second same
         t2 = tf.newTuple();
         t2.append(new DataByteArray("ccc"));
         t2.append(new DataByteArray("bbb"));
-        assertEquals("greater than tuple with lesser value", -1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 > t1.compareTo(t2));
 
         // First column less, second greater
         t2 = tf.newTuple();
         t2.append(new DataByteArray("aaa"));
         t2.append(new DataByteArray("ccc"));
-        assertEquals("greater than tuple with lesser value", 1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 < t1.compareTo(t2));
 
         // First column greater, second same
         t2 = tf.newTuple();
         t2.append(new DataByteArray("ccc"));
         t2.append(new DataByteArray("aaa"));
-        assertEquals("greater than tuple with lesser value", -1, t1.compareTo(t2));
+        assertTrue("greater than tuple with lesser value", 0 > t1.compareTo(t2));
     }
 
     @Test



Mime
View raw message