Package org.apache.hadoop.hbase
Interface CellComparator
- All Superinterfaces:
Comparator<Cell>
,Serializable
- All Known Implementing Classes:
CellComparatorImpl
,InnerStoreCellComparator
,MetaCellComparator
Comparator for comparing cells and has some specialized methods that allows comparing individual
cell components like row, family, qualifier and timestamp
-
Method Summary
Modifier and TypeMethodDescriptionint
Lexographically compares two cells.int
Compare cells.int
compareFamilies
(Cell leftCell, Cell rightCell) Lexicographically compares the families of the two cellsint
compareQualifiers
(Cell leftCell, Cell rightCell) Lexicographically compares the qualifiers of the two cellsdefault int
compareRows
(byte[] leftRow, byte[] rightRow) Compares two row bytesdefault int
compareRows
(ByteBuffer row, Cell cell) Lexicographically compare two rowsint
compareRows
(Cell cell, byte[] bytes, int offset, int length) Compares the row part of the cell with a simple plain byte[] like the stopRow in Scan.int
compareRows
(Cell leftCell, Cell rightCell) Lexographically compares the rows of two cells.int
compareTimestamps
(long leftCellts, long rightCellts) Compares cell's timestamps in DESCENDING order.int
compareTimestamps
(Cell leftCell, Cell rightCell) Compares cell's timestamps in DESCENDING order.int
compareWithoutRow
(Cell leftCell, Cell rightCell) Lexicographically compares the two cells excluding the row part.static CellComparator
A comparator for ordering cells in user-space tables.Return a dumbed-down, fast comparator for hbase2 base-type, theByteBufferKeyValue
.Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
getInstance
A comparator for ordering cells in user-space tables. Useful when writing cells in sorted order as necessary for bulk import (i.e. via MapReduce).CAUTION: This comparator may provide inaccurate ordering for cells from system tables, and should not be relied upon in that case.
-
compare
Lexographically compares two cells. The key part of the cell is taken for comparison which includes row, family, qualifier, timestamp and type- Specified by:
compare
in interfaceComparator<Cell>
- Parameters:
leftCell
- the left hand side cellrightCell
- the right hand side cell- Returns:
- greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both cells are equal
-
compare
Compare cells.- Parameters:
ignoreSequenceid
- True if we are to compare the key portion only and ignore the sequenceid. Set to false to compare key and consider sequenceid.- Returns:
- 0 if equal, -1 if a < b, and +1 if a > b.
-
compareRows
Lexographically compares the rows of two cells.- Parameters:
leftCell
- the left hand side cellrightCell
- the right hand side cell- Returns:
- greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both cells are equal
-
compareRows
Compares the row part of the cell with a simple plain byte[] like the stopRow in Scan.- Parameters:
cell
- the cellbytes
- the byte[] representing the row to be compared withoffset
- the offset of the byte[]length
- the length of the byte[]- Returns:
- greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both cells are equal
-
compareRows
Compares two row bytes- Parameters:
leftRow
- the byte array of the left rowrightRow
- the byte array of the right row- Returns:
- greater than 0 if leftRow is bigger, less than 0 if rightRow is bigger, 0 if both rows are equal
-
compareRows
Lexicographically compare two rows- Parameters:
row
- ByteBuffer that wraps a row; will read from current position and will reading all remaining; will not disturb the ByteBuffer internal state.- Returns:
- greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both cells are equal
-
compareWithoutRow
Lexicographically compares the two cells excluding the row part. It compares family, qualifier, timestamp and the type- Parameters:
leftCell
- the left hand side cellrightCell
- the right hand side cell- Returns:
- greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both cells are equal
-
compareFamilies
Lexicographically compares the families of the two cells- Parameters:
leftCell
- the left hand side cellrightCell
- the right hand side cell- Returns:
- greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both cells are equal
-
compareQualifiers
Lexicographically compares the qualifiers of the two cells- Parameters:
leftCell
- the left hand side cellrightCell
- the right hand side cell- Returns:
- greater than 0 if leftCell is bigger, less than 0 if rightCell is bigger, 0 if both cells are equal
-
compareTimestamps
Compares cell's timestamps in DESCENDING order. The below older timestamps sorting ahead of newer timestamps looks wrong but it is intentional. This way, newer timestamps are first found when we iterate over a memstore and newer versions are the first we trip over when reading from a store file.- Parameters:
leftCell
- the left hand side cellrightCell
- the right hand side cell- Returns:
- 1 if left's timestamp < right's timestamp -1 if left's timestamp > right's timestamp 0 if both timestamps are equal
-
compareTimestamps
Compares cell's timestamps in DESCENDING order. The below older timestamps sorting ahead of newer timestamps looks wrong but it is intentional. This way, newer timestamps are first found when we iterate over a memstore and newer versions are the first we trip over when reading from a store file.- Parameters:
leftCellts
- the left cell's timestamprightCellts
- the right cell's timestamp- Returns:
- 1 if left's timestamp < right's timestamp -1 if left's timestamp > right's timestamp 0 if both timestamps are equal
-
getSimpleComparator
Return a dumbed-down, fast comparator for hbase2 base-type, theByteBufferKeyValue
. 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.
-