HBASE-14524 Short-circuit comparison of rows in CellComparator. (Lars Francke)

This commit is contained in:
anoopsjohn 2016-01-05 08:47:23 +05:30
parent 998b9371c9
commit 9997e4ee52
1 changed files with 4 additions and 0 deletions

View File

@ -315,6 +315,10 @@ public class CellComparator implements Comparator<Cell>, Serializable {
* @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
*/
public int compareRows(final Cell left, final Cell right) {
// left and right can be exactly the same at the beginning of a row
if (left == right) {
return 0;
}
if (left instanceof ByteBufferedCell && right instanceof ByteBufferedCell) {
return ByteBufferUtils.compareTo(((ByteBufferedCell) left).getRowByteBuffer(),
((ByteBufferedCell) left).getRowPosition(), left.getRowLength(),