@InterfaceAudience.Private @InterfaceStability.Evolving public class CellComparatorImpl extends Object implements CellComparator
-ROOT-
or
hbase:meta
cells. Cells from these tables need a specialized comparator, one that
takes account of the special formatting of the row where we have commas to delimit table from
regionname, from row. See KeyValue for how it has a special comparator to do hbase:meta cells and
yet another for -ROOT-.
While using this comparator for {compareRows(Cell, Cell)
et al, the hbase:meta cells
format should be taken into consideration, for which the instance of this comparator should be
used. In all other cases the static APIs in this comparator would be enough
HOT methods. We spend a good portion of CPU comparing. Anything that makes the compare faster
will likely manifest at the macro level. See also BBKVComparator
. Use it when mostly
ByteBufferKeyValue
s.
Modifier and Type | Field and Description |
---|---|
static CellComparatorImpl |
COMPARATOR
Comparator for plain key/values; i.e.
|
private static long |
serialVersionUID |
Constructor and Description |
---|
CellComparatorImpl() |
Modifier and Type | Method and Description |
---|---|
int |
compare(Cell a,
Cell b)
Lexographically compares two cells.
|
int |
compare(Cell l,
Cell r,
boolean ignoreSequenceid)
Compare cells.
|
private static int |
compareBBKV(ByteBufferKeyValue left,
ByteBufferKeyValue right) |
int |
compareColumns(Cell left,
Cell right)
Compares the family and qualifier part of the cell
|
private int |
compareColumns(Cell left,
int leftFamLen,
int leftQualLen,
Cell right,
int rightFamLen,
int rightQualLen) |
int |
compareFamilies(Cell left,
Cell right)
Compare the families of left and right cell
|
private int |
compareFamilies(Cell left,
int leftFamLen,
Cell right,
int rightFamLen) |
private static int |
compareKeyValues(KeyValue left,
KeyValue right) |
private static int |
compareKVVsBBKV(KeyValue left,
ByteBufferKeyValue right) |
(package private) static int |
compareQualifiers(ByteBufferKeyValue left,
ByteBufferKeyValue right) |
(package private) static int |
compareQualifiers(ByteBufferKeyValue left,
KeyValue right) |
int |
compareQualifiers(Cell left,
Cell right)
Compare the qualifiers part of the left and right cells.
|
private int |
compareQualifiers(Cell left,
int leftQualLen,
Cell right,
int rightQualLen) |
(package private) static int |
compareQualifiers(KeyValue left,
ByteBufferKeyValue right) |
(package private) static int |
compareQualifiers(KeyValue left,
KeyValue right) |
int |
compareRows(Cell left,
byte[] right,
int roffset,
int rlength)
Compares the row part of the cell with a simple plain byte[] like the stopRow in Scan.
|
int |
compareRows(Cell left,
Cell right)
Compares the rows of the left and right cell.
|
(package private) static int |
compareRows(Cell left,
int leftRowLength,
Cell right,
int rightRowLength) |
int |
compareTimestamps(Cell left,
Cell right)
Compares cell's timestamps in DESCENDING order.
|
int |
compareTimestamps(long ltimestamp,
long rtimestamp)
Compares cell's timestamps in DESCENDING order.
|
int |
compareWithoutRow(Cell left,
Cell right)
Lexicographically compares the two cells excluding the row part.
|
static CellComparator |
getCellComparator(byte[] tableName)
Utility method that makes a guess at comparator to use based off passed tableName.
|
static CellComparator |
getCellComparator(TableName tableName)
Utility method that makes a guess at comparator to use based off passed tableName.
|
Comparator |
getSimpleComparator()
Return a dumbed-down, fast comparator for hbase2 base-type, the
ByteBufferKeyValue . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compareRows, compareRows, getInstance
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
private static final long serialVersionUID
public static final CellComparatorImpl COMPARATOR
public CellComparatorImpl()
public final int compare(Cell a, Cell b)
CellComparator
compare
in interface Comparator<Cell>
compare
in interface CellComparator
a
- the left hand side cellb
- the right hand side cellpublic int compare(Cell l, Cell r, boolean ignoreSequenceid)
CellComparator
compare
in interface CellComparator
ignoreSequenceid
- True if we are to compare the key portion only and ignore the
sequenceid. Set to false to compare key and consider sequenceid.private static int compareKeyValues(KeyValue left, KeyValue right)
private static int compareBBKV(ByteBufferKeyValue left, ByteBufferKeyValue right)
private static int compareKVVsBBKV(KeyValue left, ByteBufferKeyValue right)
public final int compareColumns(Cell left, Cell right)
private int compareColumns(Cell left, int leftFamLen, int leftQualLen, Cell right, int rightFamLen, int rightQualLen)
private int compareFamilies(Cell left, int leftFamLen, Cell right, int rightFamLen)
private final int compareQualifiers(Cell left, int leftQualLen, Cell right, int rightQualLen)
public final int compareFamilies(Cell left, Cell right)
compareFamilies
in interface CellComparator
left
- the left hand side cellright
- the right hand side cellstatic int compareQualifiers(KeyValue left, KeyValue right)
static int compareQualifiers(KeyValue left, ByteBufferKeyValue right)
static int compareQualifiers(ByteBufferKeyValue left, KeyValue right)
static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right)
public final int compareQualifiers(Cell left, Cell right)
compareQualifiers
in interface CellComparator
left
- the left hand side cellright
- the right hand side cellpublic int compareRows(Cell left, Cell right)
compareRows
in interface CellComparator
left
- the left hand side cellright
- the right hand side cellstatic int compareRows(Cell left, int leftRowLength, Cell right, int rightRowLength)
public int compareRows(Cell left, byte[] right, int roffset, int rlength)
MetaCellComparator.META_COMPARATOR
should be used n * the cell to be compared n * the
kv serialized byte[] to be compared with n * the offset in the byte[] n * the length in the
byte[]compareRows
in interface CellComparator
left
- the cellright
- the byte[] representing the row to be compared withroffset
- the offset of the byte[]rlength
- the length of the byte[]public final int compareWithoutRow(Cell left, Cell right)
CellComparator
compareWithoutRow
in interface CellComparator
left
- the left hand side cellright
- the right hand side cellpublic int compareTimestamps(Cell left, Cell right)
CellComparator
compareTimestamps
in interface CellComparator
left
- the left hand side cellright
- the right hand side cellpublic int compareTimestamps(long ltimestamp, long rtimestamp)
CellComparator
compareTimestamps
in interface CellComparator
ltimestamp
- the left cell's timestamprtimestamp
- the right cell's timestamppublic Comparator getSimpleComparator()
CellComparator
ByteBufferKeyValue
.
Create an instance when you make a new memstore, when you know only BBKVs will be passed. Do
not pollute with types other than BBKV if can be helped; the Comparator will slow.getSimpleComparator
in interface CellComparator
public static CellComparator getCellComparator(TableName tableName)
tableName
passed.public static CellComparator getCellComparator(byte[] tableName)
tableName
passed.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.