hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjus...@apache.org
Subject svn commit: r1485920 - /hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
Date Fri, 24 May 2013 01:51:50 GMT
Author: zjushch
Date: Fri May 24 01:51:49 2013
New Revision: 1485920

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

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

Modified: hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java?rev=1485920&r1=1485919&r2=1485920&view=diff
==============================================================================
--- hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java (original)
+++ hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java Fri
May 24 01:51:49 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(),



Mime
View raw message