From 99d54246ee7a22cb0fa01a468d57fa6b40114394 Mon Sep 17 00:00:00 2001 From: Ankit Singhal Date: Tue, 26 Jun 2018 16:46:44 -0700 Subject: [PATCH] HBASE-20795 Allow option in BBKVComparator.compare to do comparison without sequence id Signed-off-by: Michael Stack --- .../main/java/org/apache/hadoop/hbase/BBKVComparator.java | 7 ++++--- .../java/org/apache/hadoop/hbase/CellComparatorImpl.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/BBKVComparator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/BBKVComparator.java index c15d32110ad..017586df582 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/BBKVComparator.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/BBKVComparator.java @@ -73,7 +73,7 @@ public class BBKVComparator implements Comparator { public int compare(Object l, Object r) { // LOG.info("ltype={} rtype={}", l, r); if ((l instanceof ByteBufferKeyValue) && (r instanceof ByteBufferKeyValue)) { - return compare((ByteBufferKeyValue)l, (ByteBufferKeyValue)r); + return compare((ByteBufferKeyValue)l, (ByteBufferKeyValue)r, false); } // Skip calling compare(Object, Object) and go direct to compare(Cell, Cell) return this.fallback.compare((Cell)l, (Cell)r); @@ -81,7 +81,8 @@ public class BBKVComparator implements Comparator { // TODO: Come back here. We get a few percentage points extra of throughput if this is a // private method. - static final int compare(ByteBufferKeyValue left, ByteBufferKeyValue right) { + static final int compare(ByteBufferKeyValue left, ByteBufferKeyValue right, + boolean ignoreSequenceid) { // NOTE: Same method is in CellComparatorImpl, also private, not shared, intentionally. Not // sharing gets us a few percent more throughput in compares. If changes here or there, make // sure done in both places. @@ -168,6 +169,6 @@ public class BBKVComparator implements Comparator { } // Negate following comparisons so later edits show up first mvccVersion: later sorts first - return Longs.compare(right.getSequenceId(), left.getSequenceId()); + return ignoreSequenceid ? diff : Longs.compare(right.getSequenceId(), left.getSequenceId()); } } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java index c2f2ea55d52..707d919c280 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java @@ -74,7 +74,7 @@ public class CellComparatorImpl implements CellComparator { int diff = 0; // "Peel off" the most common path. if (a instanceof ByteBufferKeyValue && b instanceof ByteBufferKeyValue) { - diff = BBKVComparator.compare((ByteBufferKeyValue)a, (ByteBufferKeyValue)b); + diff = BBKVComparator.compare((ByteBufferKeyValue)a, (ByteBufferKeyValue)b, ignoreSequenceid); if (diff != 0) { return diff; }