You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zj...@apache.org on 2013/05/24 03:54:00 UTC

svn commit: r1485921 - /hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java

Author: zjushch
Date: Fri May 24 01:54:00 2013
New Revision: 1485921

URL: http://svn.apache.org/r1485921
Log:
HBASE-8433 CellComparator#compare returns incorrect result for faked KeyValue

Modified:
    hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java

Modified: hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java?rev=1485921&r1=1485920&r2=1485921&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java (original)
+++ hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java Fri May 24 01:54:00 2013
@@ -23,6 +23,7 @@ import java.util.Comparator;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
+import org.apache.hadoop.hbase.KeyValue.Type;
 import org.apache.hadoop.hbase.util.Bytes;
 
 import com.google.common.primitives.Longs;
@@ -55,6 +56,19 @@ public class CellComparator implements C
         b.getRowArray(), b.getRowOffset(), b.getRowLength());
     if (c != 0) return c;
 
+    // If the column is not specified, the "minimum" key type appears the
+    // latest in the sorted order, regardless of the timestamp. This is used
+    // for specifying the last key/value in a given row, because there is no
+    // "lexicographically last column" (it would be infinitely long). The
+    // "maximum" key type does not need this behavior.
+    if (a.getFamilyLength() == 0 && a.getTypeByte() == Type.Minimum.getCode()) {
+      // a is "bigger", i.e. it appears later in the sorted order
+      return 1;
+    }
+    if (b.getFamilyLength() == 0 && b.getTypeByte() == Type.Minimum.getCode()) {
+      return -1;
+    }
+
     //family
     c = Bytes.compareTo(
       a.getFamilyArray(), a.getFamilyOffset(), a.getFamilyLength(),