HBASE-8433 CellComparator#compare returns incorrect result for faked KeyValue

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1485920 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
zjushch 2013-05-24 01:51:49 +00:00
parent bd7b479807
commit 23da6d4cd3
1 changed files with 14 additions and 0 deletions

View File

@ -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 Comparator<Cell>, Serializable{
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(),