HBASE-14524 Short-circuit comparison of rows in CellComparator. (Lars Francke)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9997e4ee Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9997e4ee Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9997e4ee Branch: refs/heads/trunk Commit: 9997e4ee52136a681faa825dea46bd1162d71eca Parents: 998b937 Author: anoopsjohn <anoopsamj...@gmail.com> Authored: Tue Jan 5 08:47:23 2016 +0530 Committer: anoopsjohn <anoopsamj...@gmail.com> Committed: Tue Jan 5 08:47:23 2016 +0530 ---------------------------------------------------------------------- .../src/main/java/org/apache/hadoop/hbase/CellComparator.java | 4 ++++ 1 file changed, 4 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/9997e4ee/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparator.java ---------------------------------------------------------------------- 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 7002762..b179963 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,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(),