From 7e93d789446c1121d417381b1de19e68af38230f Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Wed, 30 Sep 2015 14:11:39 +0200 Subject: [PATCH] [HBASE-14524] Short-circuit comparison of rows in CellComparator --- .../src/main/java/org/apache/hadoop/hbase/CellComparator.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java index 47a210b..dba60ff 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java @@ -315,6 +315,11 @@ public class CellComparator implements Comparator, 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).getRowPositionInByteBuffer(), left.getRowLength(), -- 2.4.3