From 9396d729ac0c0c28e6ff30169b2f2d9a5d3ef57f Mon Sep 17 00:00:00 2001
From: ZXX_y <3514002329@qq.com>
Date: Wed, 15 Oct 2025 12:49:30 +0800
Subject: [PATCH 1/4] HBASE-29658: Add RISC-V Vector (RVV) optimizations
---
.../hadoop/hbase/CellComparatorImpl.java | 491 +++
.../hadoop/hbase/util/RVVByteBufferUtils.java | 55 +
.../org/apache/hadoop/hbase/util/ScanRVV.java | 130 +
.../hbase/io/compress/lz4/Lz4Compressor.java | 78 +
.../hbase/io/compress/lz4/Lz4Native.java | 27 +
.../hbase/io/compress/lz4/NativeLoader.java | 39 +
.../src/native/Lz4Native.c | 72 +
.../hbase-compression-lz4/src/native/lz4.c | 3250 +++++++++++++++++
.../hbase-compression-lz4/src/native/lz4.h | 886 +++++
.../io/hfile/CompoundBloomFilterWriter.java | 58 +
.../hbase/regionserver/StoreScanner.java | 168 +
.../hadoop/hbase/util/BloomFilterChunk.java | 249 ++
.../hbase/util/BloomFilterRvvNative.java | 69 +
.../src/main/native/bloomfilter_rvv.c | 286 ++
.../src/main/native/bloomfilter_rvv.h | 20 +
hbase-server/src/main/native/scan_rvv.c | 119 +
hbase-server/src/main/native/scan_rvv.h | 36 +
hbase-server/src/main/native/scan_rvv_jni.c | 549 +++
18 files changed, 6582 insertions(+)
create mode 100644 hbase-common/src/main/java/org/apache/hadoop/hbase/util/RVVByteBufferUtils.java
create mode 100644 hbase-common/src/main/java/org/apache/hadoop/hbase/util/ScanRVV.java
create mode 100644 hbase-compression/hbase-compression-lz4/src/main/java/org/apache/hadoop/hbase/io/compress/lz4/Lz4Native.java
create mode 100644 hbase-compression/hbase-compression-lz4/src/main/java/org/apache/hadoop/hbase/io/compress/lz4/NativeLoader.java
create mode 100644 hbase-compression/hbase-compression-lz4/src/native/Lz4Native.c
create mode 100644 hbase-compression/hbase-compression-lz4/src/native/lz4.c
create mode 100644 hbase-compression/hbase-compression-lz4/src/native/lz4.h
create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/util/BloomFilterRvvNative.java
create mode 100644 hbase-server/src/main/native/bloomfilter_rvv.c
create mode 100644 hbase-server/src/main/native/bloomfilter_rvv.h
create mode 100644 hbase-server/src/main/native/scan_rvv.c
create mode 100644 hbase-server/src/main/native/scan_rvv.h
create mode 100644 hbase-server/src/main/native/scan_rvv_jni.c
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 0e6a53ca7c47..0b2c8d3f30bb 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
@@ -24,6 +24,7 @@
import org.apache.yetus.audience.InterfaceStability;
/**
+<<<<<<< HEAD
* Compare two HBase cells. Do not use this method comparing -ROOT- or
* hbase:meta cells. Cells from these tables need a specialized comparator, one that
* takes account of the special formatting of the row where we have commas to delimit table from
@@ -41,6 +42,33 @@
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UNKNOWN",
justification = "Findbugs doesn't like the way we are negating the result of"
+ " a compare in below")
+=======
+ * Compare two HBase cells. Do not use this method comparing -ROOT-
+ * or
+ * hbase:meta cells. Cells from these tables need a specialized
+ * comparator, one that
+ * takes account of the special formatting of the row where we have commas to
+ * delimit table from
+ * regionname, from row. See KeyValue for how it has a special comparator to do
+ * hbase:meta cells and
+ * yet another for -ROOT-.
+ *
+ * While using this comparator for {{@link #compareRows(Cell, Cell)} et al, the + * hbase:meta cells + * format should be taken into consideration, for which the instance of this + * comparator should be + * used. In all other cases the static APIs in this comparator would be enough + *
+ * HOT methods. We spend a good portion of CPU comparing. Anything that makes + * the compare faster + * will likely manifest at the macro level. See also {@link BBKVComparator}. Use + * it when mostly + * {@link ByteBufferKeyValue}s. + *
+ */ +@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UNKNOWN", justification = "Findbugs doesn't like the way we are negating the result of" + + " a compare in below") +>>>>>>> rvv-optimization @InterfaceAudience.Private @InterfaceStability.Evolving public class CellComparatorImpl implements CellComparator { @@ -48,7 +76,12 @@ public class CellComparatorImpl implements CellComparator { private static final long serialVersionUID = 8186411895799094989L; /** +<<<<<<< HEAD * Comparator for plain key/values; i.e. non-catalog table key/values. Works on Key portion of +======= + * Comparator for plain key/values; i.e. non-catalog table key/values. Works on + * Key portion of +>>>>>>> rvv-optimization * KeyValue only. */ public static final CellComparatorImpl COMPARATOR = new CellComparatorImpl(); @@ -96,6 +129,7 @@ public int compare(final Cell l, final Cell r, boolean ignoreSequenceid) { return diff; } } +<<<<<<< HEAD if (ignoreSequenceid) { return diff; @@ -105,36 +139,68 @@ public int compare(final Cell l, final Cell r, boolean ignoreSequenceid) { } private int compareKeyValues(final KeyValue left, final KeyValue right) { +======= + // Negate following comparisons so later edits show up first mvccVersion: later + // sorts first + return ignoreSequenceid ? diff : Long.compare(r.getSequenceId(), l.getSequenceId()); + } + + private static int compareKeyValues(final KeyValue left, final KeyValue right) { +>>>>>>> rvv-optimization int diff; // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); diff = Bytes.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength, +<<<<<<< HEAD right.getRowArray(), right.getRowOffset(), rightRowLength); +======= + right.getRowArray(), right.getRowOffset(), rightRowLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } +<<<<<<< HEAD // If the column is not specified, the "minimum" key type appears as latest in the sorted // order, regardless of the timestamp. This is used for specifying the last key/value in a // given row, because there is no "lexicographically last column" (it would be infinitely // long). // The "maximum" key type does not need this behavior. Copied from KeyValue. This is bad in +======= + // If the column is not specified, the "minimum" key type appears as latest in + // the sorted + // order, regardless of the timestamp. This is used for specifying the last + // key/value in a + // given row, because there is no "lexicographically last column" (it would be + // infinitely + // long). + // The "maximum" key type does not need this behavior. Copied from KeyValue. + // This is bad in +>>>>>>> rvv-optimization // that // we can't do memcmp w/ special rules like this. // TODO: Is there a test for this behavior? int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); +<<<<<<< HEAD int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +======= + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +>>>>>>> rvv-optimization // No need of left row length below here. byte leftType = left.getTypeByte(leftKeyLength); +<<<<<<< HEAD if ( leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0 ) { +======= + if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) { +>>>>>>> rvv-optimization // left is "bigger", i.e. it appears later in the sorted order return 1; } @@ -142,32 +208,51 @@ private int compareKeyValues(final KeyValue left, final KeyValue right) { int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); +<<<<<<< HEAD int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +======= + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +>>>>>>> rvv-optimization // No need of right row length below here. byte rightType = right.getTypeByte(rightKeyLength); +<<<<<<< HEAD if ( rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0 ) { +======= + if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) { +>>>>>>> rvv-optimization return -1; } // Compare families. int leftFamilyPosition = left.getFamilyOffset(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyOffset(rightFamilyLengthPosition); +<<<<<<< HEAD diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition, rightFamilyLength); +======= + diff = Bytes.compareTo(left.getFamilyArray(), leftFamilyPosition, leftFamilyLength, + right.getFamilyArray(), rightFamilyPosition, rightFamilyLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } // Compare qualifiers diff = Bytes.compareTo(left.getQualifierArray(), +<<<<<<< HEAD left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength, right.getQualifierArray(), right.getQualifierOffset(rightFamilyPosition, rightFamilyLength), rightQualifierLength); +======= + left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength, + right.getQualifierArray(), right.getQualifierOffset(rightFamilyPosition, rightFamilyLength), + rightQualifierLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } @@ -187,37 +272,65 @@ private int compareKeyValues(final KeyValue left, final KeyValue right) { return (0xff & rightType) - (0xff & leftType); } +<<<<<<< HEAD private int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) { +======= + private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) { +>>>>>>> rvv-optimization int diff; // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); diff = ByteBufferUtils.compareTo(left.getRowByteBuffer(), left.getRowPosition(), leftRowLength, +<<<<<<< HEAD right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); +======= + right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } +<<<<<<< HEAD // If the column is not specified, the "minimum" key type appears as latest in the sorted // order, regardless of the timestamp. This is used for specifying the last key/value in a // given row, because there is no "lexicographically last column" (it would be infinitely // long). // The "maximum" key type does not need this behavior. Copied from KeyValue. This is bad in +======= + // If the column is not specified, the "minimum" key type appears as latest in + // the sorted + // order, regardless of the timestamp. This is used for specifying the last + // key/value in a + // given row, because there is no "lexicographically last column" (it would be + // infinitely + // long). + // The "maximum" key type does not need this behavior. Copied from KeyValue. + // This is bad in +>>>>>>> rvv-optimization // that // we can't do memcmp w/ special rules like this. // TODO: Is there a test for this behavior? int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); +<<<<<<< HEAD int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +======= + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +>>>>>>> rvv-optimization // No need of left row length below here. byte leftType = left.getTypeByte(leftKeyLength); +<<<<<<< HEAD if ( leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0 ) { +======= + if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) { +>>>>>>> rvv-optimization // left is "bigger", i.e. it appears later in the sorted order return 1; } @@ -225,32 +338,52 @@ private int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); +<<<<<<< HEAD int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +======= + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +>>>>>>> rvv-optimization // No need of right row length below here. byte rightType = right.getTypeByte(rightKeyLength); +<<<<<<< HEAD if ( rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0 ) { +======= + if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) { +>>>>>>> rvv-optimization return -1; } // Compare families. int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); +<<<<<<< HEAD diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition, rightFamilyLength); +======= + diff = ByteBufferUtils.compareToRvv(left.getFamilyByteBuffer(), leftFamilyPosition, + leftFamilyLength, right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } // Compare qualifiers +<<<<<<< HEAD diff = ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength, right.getQualifierByteBuffer(), right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); +======= + diff = ByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(), + left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength, + right.getQualifierByteBuffer(), + right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } @@ -269,37 +402,66 @@ private int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue return (0xff & rightType) - (0xff & leftType); } +<<<<<<< HEAD private int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) { +======= + private static int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) { +>>>>>>> rvv-optimization int diff; // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); +<<<<<<< HEAD diff = ByteBufferUtils.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength, right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); +======= + diff = ByteBufferUtils.compareToRvv(right.getRowByteBuffer(), right.getRowPosition(), rightRowLength, + left.getRowArray(), left.getRowOffset(), leftRowLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } +<<<<<<< HEAD // If the column is not specified, the "minimum" key type appears as latest in the sorted // order, regardless of the timestamp. This is used for specifying the last key/value in a // given row, because there is no "lexicographically last column" (it would be infinitely // long). // The "maximum" key type does not need this behavior. Copied from KeyValue. This is bad in +======= + // If the column is not specified, the "minimum" key type appears as latest in + // the sorted + // order, regardless of the timestamp. This is used for specifying the last + // key/value in a + // given row, because there is no "lexicographically last column" (it would be + // infinitely + // long). + // The "maximum" key type does not need this behavior. Copied from KeyValue. + // This is bad in +>>>>>>> rvv-optimization // that // we can't do memcmp w/ special rules like this. // TODO: Is there a test for this behavior? int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); +<<<<<<< HEAD int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +======= + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +>>>>>>> rvv-optimization // No need of left row length below here. byte leftType = left.getTypeByte(leftKeyLength); +<<<<<<< HEAD if ( leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0 ) { +======= + if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) { +>>>>>>> rvv-optimization // left is "bigger", i.e. it appears later in the sorted order return 1; } @@ -307,32 +469,52 @@ private int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); +<<<<<<< HEAD int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +======= + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +>>>>>>> rvv-optimization // No need of right row length below here. byte rightType = right.getTypeByte(rightKeyLength); +<<<<<<< HEAD if ( rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0 ) { +======= + if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) { +>>>>>>> rvv-optimization return -1; } // Compare families. int leftFamilyPosition = left.getFamilyOffset(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); +<<<<<<< HEAD diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition, rightFamilyLength); +======= + diff = ByteBufferUtils.compareToRvv(right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength, + left.getFamilyArray(), leftFamilyPosition, leftFamilyLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } // Compare qualifiers +<<<<<<< HEAD diff = ByteBufferUtils.compareTo(left.getQualifierArray(), left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength, right.getQualifierByteBuffer(), right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); +======= + diff = ByteBufferUtils.compareToRvv(right.getQualifierByteBuffer(), + right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength, + left.getQualifierArray(), + left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength); +>>>>>>> rvv-optimization if (diff != 0) { return diff; } @@ -353,7 +535,13 @@ private int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) /** * Compares the family and qualifier part of the cell +<<<<<<< HEAD * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise +======= + * + * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 + * otherwise +>>>>>>> rvv-optimization */ public final int compareColumns(final Cell left, final Cell right) { int diff = compareFamilies(left, right); @@ -364,7 +552,11 @@ public final int compareColumns(final Cell left, final Cell right) { } private int compareColumns(final Cell left, final int leftFamLen, final int leftQualLen, +<<<<<<< HEAD final Cell right, final int rightFamLen, final int rightQualLen) { +======= + final Cell right, final int rightFamLen, final int rightQualLen) { +>>>>>>> rvv-optimization int diff = compareFamilies(left, leftFamLen, right, rightFamLen); if (diff != 0) { return diff; @@ -372,6 +564,7 @@ private int compareColumns(final Cell left, final int leftFamLen, final int left return compareQualifiers(left, leftQualLen, right, rightQualLen); } +<<<<<<< HEAD /** * This method will be overridden when we compare cells inner store to bypass family comparing. */ @@ -389,19 +582,45 @@ protected int compareFamilies(Cell left, int leftFamLen, Cell right, int rightFa } if (right instanceof ByteBufferExtendedCell) { // Notice how we flip the order of the compare here. We used to negate the return value but +======= + private int compareFamilies(Cell left, int leftFamLen, Cell right, int rightFamLen) { + if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) left).getFamilyPosition(), leftFamLen, + ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen); + } + if (left instanceof ByteBufferExtendedCell) { + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) left).getFamilyPosition(), leftFamLen, right.getFamilyArray(), + right.getFamilyOffset(), rightFamLen); + } + if (right instanceof ByteBufferExtendedCell) { + // Notice how we flip the order of the compare here. We used to negate the + // return value but +>>>>>>> rvv-optimization // see what FindBugs says // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO // It suggest flipping the order to get same effect and 'safer'. return ByteBufferUtils.compareTo(left.getFamilyArray(), left.getFamilyOffset(), leftFamLen, +<<<<<<< HEAD ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), ((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen); } return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), leftFamLen, right.getFamilyArray(), right.getFamilyOffset(), rightFamLen); +======= + ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen); + } + return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), leftFamLen, + right.getFamilyArray(), right.getFamilyOffset(), rightFamLen); +>>>>>>> rvv-optimization } private final int compareQualifiers(Cell left, int leftQualLen, Cell right, int rightQualLen) { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { +<<<<<<< HEAD return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), ((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen, ((ByteBufferExtendedCell) right).getQualifierByteBuffer(), @@ -423,15 +642,46 @@ private final int compareQualifiers(Cell left, int leftQualLen, Cell right, int } return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(), leftQualLen, right.getQualifierArray(), right.getQualifierOffset(), rightQualLen); +======= + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen, + ((ByteBufferExtendedCell) right).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) right).getQualifierPosition(), rightQualLen); + } + if (left instanceof ByteBufferExtendedCell) { + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen, + right.getQualifierArray(), right.getQualifierOffset(), rightQualLen); + } + if (right instanceof ByteBufferExtendedCell) { + // Notice how we flip the order of the compare here. We used to negate the + // return value but + // see what FindBugs says + // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO + // It suggest flipping the order to get same effect and 'safer'. + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) right).getQualifierPosition(), rightQualLen, + left.getQualifierArray(), left.getQualifierOffset(), leftQualLen); + } + return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(), leftQualLen, + right.getQualifierArray(), right.getQualifierOffset(), rightQualLen); +>>>>>>> rvv-optimization } /** * Compare the families of left and right cell +<<<<<<< HEAD * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise +======= + * + * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 + * otherwise +>>>>>>> rvv-optimization */ @Override public final int compareFamilies(Cell left, Cell right) { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { +<<<<<<< HEAD return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(), ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(), ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), @@ -486,6 +736,37 @@ protected int compareFamilies(KeyValue left, int leftFamilyPosition, int leftFam static int compareQualifiers(KeyValue left, KeyValue right) { // 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 +======= + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(), + ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength()); + } + if (left instanceof ByteBufferExtendedCell) { + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(), + right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength()); + } + if (right instanceof ByteBufferExtendedCell) { + // Notice how we flip the order of the compare here. We used to negate the + // return value but + // see what FindBugs says + // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO + // It suggest flipping the order to get same effect and 'safer'. + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength(), + left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength()); + } + return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(), + right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength()); + } + + static int compareQualifiers(KeyValue left, KeyValue right) { + // 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 +>>>>>>> rvv-optimization // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -494,22 +775,31 @@ static int compareQualifiers(KeyValue left, KeyValue right) { int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); +<<<<<<< HEAD int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +======= + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +>>>>>>> rvv-optimization // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); +<<<<<<< HEAD int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +======= + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +>>>>>>> rvv-optimization // Compare families. int leftFamilyOffset = left.getFamilyOffset(leftFamilyLengthPosition); int rightFamilyOffset = right.getFamilyOffset(rightFamilyLengthPosition); // Compare qualifiers +<<<<<<< HEAD return Bytes.compareTo(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength, leftQualifierLength, right.getQualifierArray(), rightFamilyOffset + rightFamilyLength, rightQualifierLength); @@ -518,6 +808,18 @@ static int compareQualifiers(KeyValue left, KeyValue right) { static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) { // 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 +======= + return ByteBufferUtils.compareToRvv(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength, + leftQualifierLength, right.getQualifierArray(), rightFamilyOffset + rightFamilyLength, + rightQualifierLength); + } + + static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) { + // 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 +>>>>>>> rvv-optimization // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -526,22 +828,31 @@ static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) { int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); +<<<<<<< HEAD int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +======= + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +>>>>>>> rvv-optimization // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); +<<<<<<< HEAD int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +======= + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +>>>>>>> rvv-optimization // Compare families. int leftFamilyOffset = left.getFamilyOffset(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); // Compare qualifiers +<<<<<<< HEAD return ByteBufferUtils.compareTo(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength, leftQualifierLength, right.getQualifierByteBuffer(), rightFamilyPosition + rightFamilyLength, rightQualifierLength); @@ -550,6 +861,18 @@ static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) { static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) { // 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 +======= + return ByteBufferUtils.compareToRvv(right.getQualifierByteBuffer(), rightFamilyPosition + rightFamilyLength, + rightQualifierLength, left.getQualifierArray(), leftFamilyOffset + leftFamilyLength, + leftQualifierLength); + } + + static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) { + // 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 +>>>>>>> rvv-optimization // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -558,22 +881,31 @@ static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) { int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); +<<<<<<< HEAD int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +======= + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +>>>>>>> rvv-optimization // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); +<<<<<<< HEAD int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +======= + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +>>>>>>> rvv-optimization // Compare families. int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); int rightFamilyOffset = right.getFamilyOffset(rightFamilyLengthPosition); // Compare qualifiers +<<<<<<< HEAD return ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierArray(), rightFamilyOffset + rightFamilyLength, rightQualifierLength); @@ -582,6 +914,18 @@ static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) { static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right) { // 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 +======= + return ByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(), + leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierArray(), + rightFamilyOffset + rightFamilyLength, rightQualifierLength); + } + + static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right) { + // 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 +>>>>>>> rvv-optimization // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -590,30 +934,50 @@ static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right) int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); +<<<<<<< HEAD int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +======= + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); +>>>>>>> rvv-optimization // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); +<<<<<<< HEAD int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +======= + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); +>>>>>>> rvv-optimization // Compare families. int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); // Compare qualifiers +<<<<<<< HEAD return ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierByteBuffer(), rightFamilyPosition + rightFamilyLength, rightQualifierLength); +======= + return ByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(), + leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierByteBuffer(), + rightFamilyPosition + rightFamilyLength, rightQualifierLength); +>>>>>>> rvv-optimization } /** * Compare the qualifiers part of the left and right cells. +<<<<<<< HEAD * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise +======= + * + * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 + * otherwise +>>>>>>> rvv-optimization */ @Override public final int compareQualifiers(Cell left, Cell right) { @@ -627,6 +991,7 @@ public final int compareQualifiers(Cell left, Cell right) { return compareQualifiers((ByteBufferKeyValue) left, (KeyValue) right); } else { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { +<<<<<<< HEAD return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(), ((ByteBufferExtendedCell) right).getQualifierByteBuffer(), @@ -649,15 +1014,51 @@ public final int compareQualifiers(Cell left, Cell right) { return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(), left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength()); +======= + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(), + ((ByteBufferExtendedCell) right).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) right).getQualifierPosition(), right.getQualifierLength()); + } + if (left instanceof ByteBufferExtendedCell) { + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(), + right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength()); + } + if (right instanceof ByteBufferExtendedCell) { + // Notice how we flip the order of the compare here. We used to negate the + // return value but + // see what FindBugs says + // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO + // It suggest flipping the order to get same effect and 'safer'. + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getQualifierByteBuffer(), + ((ByteBufferExtendedCell) right).getQualifierPosition(), right.getQualifierLength(), + left.getQualifierArray(), left.getQualifierOffset(), left.getQualifierLength()); + } + return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(), + left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(), + right.getQualifierLength()); +>>>>>>> rvv-optimization } } /** +<<<<<<< HEAD * Compares the rows of the left and right cell. For the hbase:meta case this method is overridden * such that it can handle hbase:meta cells. The caller should ensure using the appropriate * comparator for hbase:meta. * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise +======= + * Compares the rows of the left and right cell. For the hbase:meta case this + * method is overridden + * such that it can handle hbase:meta cells. The caller should ensure using the + * appropriate + * comparator for hbase:meta. + * + * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 + * otherwise +>>>>>>> rvv-optimization */ @Override public int compareRows(final Cell left, final Cell right) { @@ -670,6 +1071,7 @@ static int compareRows(final Cell left, int leftRowLength, final Cell right, int return 0; } if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { +<<<<<<< HEAD return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(), ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength, ((ByteBufferExtendedCell) right).getRowByteBuffer(), @@ -699,17 +1101,63 @@ static int compareRows(final Cell left, int leftRowLength, final Cell right, int * {{@link MetaCellComparator#META_COMPARATOR} should be used the cell to be compared the kv * serialized byte[] to be compared with the offset in the byte[] the length in the byte[] * @return 0 if both cell and the byte[] are equal, 1 if the cell is bigger than byte[], -1 +======= + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getRowByteBuffer(), + ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength, + ((ByteBufferExtendedCell) right).getRowByteBuffer(), + ((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength); + } + if (left instanceof ByteBufferExtendedCell) { + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getRowByteBuffer(), + ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength, right.getRowArray(), + right.getRowOffset(), rightRowLength); + } + if (right instanceof ByteBufferExtendedCell) { + // Notice how we flip the order of the compare here. We used to negate the + // return value but + // see what FindBugs says + // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO + // It suggest flipping the order to get same effect and 'safer'. + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getRowByteBuffer(), + ((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength, + left.getRowArray(), left.getRowOffset(), leftRowLength); + } + return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength, + right.getRowArray(), right.getRowOffset(), rightRowLength); + } + + /** + * Compares the row part of the cell with a simple plain byte[] like the stopRow + * in Scan. This + * should be used with context where for hbase:meta cells the + * {{@link MetaCellComparator#META_COMPARATOR} should be used the cell to be + * compared the kv + * serialized byte[] to be compared with the offset in the byte[] the length in + * the byte[] + * + * @return 0 if both cell and the byte[] are equal, 1 if the cell is bigger than + * byte[], -1 +>>>>>>> rvv-optimization * otherwise */ @Override public int compareRows(Cell left, byte[] right, int roffset, int rlength) { if (left instanceof ByteBufferExtendedCell) { +<<<<<<< HEAD return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(), ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right, roffset, rlength); } return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right, roffset, rlength); +======= + return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getRowByteBuffer(), + ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right, roffset, + rlength); + } + return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right, + roffset, rlength); +>>>>>>> rvv-optimization } @Override @@ -719,11 +1167,17 @@ public final int compareWithoutRow(final Cell left, final Cell right) { // for specifying the last key/value in a given row, because there is no // "lexicographically last column" (it would be infinitely long). The // "maximum" key type does not need this behavior. +<<<<<<< HEAD // Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules like this. +======= + // Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules + // like this. +>>>>>>> rvv-optimization int lFamLength = left.getFamilyLength(); int rFamLength = right.getFamilyLength(); int lQualLength = left.getQualifierLength(); int rQualLength = right.getQualifierLength(); +<<<<<<< HEAD byte leftType = PrivateCellUtil.getTypeByte(left); byte rightType = PrivateCellUtil.getTypeByte(right); if (lFamLength + lQualLength == 0 && leftType == KeyValue.Type.Minimum.getCode()) { @@ -731,6 +1185,13 @@ public final int compareWithoutRow(final Cell left, final Cell right) { return 1; } if (rFamLength + rQualLength == 0 && rightType == KeyValue.Type.Minimum.getCode()) { +======= + if (lFamLength + lQualLength == 0 && left.getTypeByte() == KeyValue.Type.Minimum.getCode()) { + // left is "bigger", i.e. it appears later in the sorted order + return 1; + } + if (rFamLength + rQualLength == 0 && right.getTypeByte() == KeyValue.Type.Minimum.getCode()) { +>>>>>>> rvv-optimization return -1; } if (lFamLength != rFamLength) { @@ -752,7 +1213,11 @@ public final int compareWithoutRow(final Cell left, final Cell right) { // of higher numbers sort before those of lesser numbers. Maximum (255) // appears ahead of everything, and minimum (0) appears after // everything. +<<<<<<< HEAD return (0xff & rightType) - (0xff & leftType); +======= + return (0xff & right.getTypeByte()) - (0xff & left.getTypeByte()); +>>>>>>> rvv-optimization } @Override @@ -767,13 +1232,24 @@ public int compareTimestamps(final long ltimestamp, final long rtimestamp) { } @Override +<<<<<<< HEAD public Comparator-ROOT- or
- * hbase:meta cells. Cells from these tables need a specialized comparator, one that
- * takes account of the special formatting of the row where we have commas to delimit table from
- * regionname, from row. See KeyValue for how it has a special comparator to do hbase:meta cells and
- * yet another for -ROOT-.
- * - * While using this comparator for {{@link #compareRows(Cell, Cell)} et al, the hbase:meta cells - * format should be taken into consideration, for which the instance of this comparator should be - * used. In all other cases the static APIs in this comparator would be enough - *
- * HOT methods. We spend a good portion of CPU comparing. Anything that makes the compare faster - * will likely manifest at the macro level. - *
- */ -@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UNKNOWN", - justification = "Findbugs doesn't like the way we are negating the result of" - + " a compare in below") -======= * Compare two HBase cells. Do not use this method comparing-ROOT-
* or
* hbase:meta cells. Cells from these tables need a specialized
@@ -68,7 +50,6 @@
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UNKNOWN", justification = "Findbugs doesn't like the way we are negating the result of"
+ " a compare in below")
->>>>>>> rvv-optimization
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class CellComparatorImpl implements CellComparator {
@@ -76,12 +57,8 @@ public class CellComparatorImpl implements CellComparator {
private static final long serialVersionUID = 8186411895799094989L;
/**
-<<<<<<< HEAD
- * Comparator for plain key/values; i.e. non-catalog table key/values. Works on Key portion of
-=======
* Comparator for plain key/values; i.e. non-catalog table key/values. Works on
* Key portion of
->>>>>>> rvv-optimization
* KeyValue only.
*/
public static final CellComparatorImpl COMPARATOR = new CellComparatorImpl();
@@ -129,45 +106,22 @@ public int compare(final Cell l, final Cell r, boolean ignoreSequenceid) {
return diff;
}
}
-<<<<<<< HEAD
-
- if (ignoreSequenceid) {
- return diff;
- }
- // Negate following comparisons so later edits show up first mvccVersion: later sorts first
- return Long.compare(PrivateCellUtil.getSequenceId(r), PrivateCellUtil.getSequenceId(l));
- }
-
- private int compareKeyValues(final KeyValue left, final KeyValue right) {
-=======
// Negate following comparisons so later edits show up first mvccVersion: later
// sorts first
- return ignoreSequenceid ? diff : Long.compare(r.getSequenceId(), l.getSequenceId());
+ return ignoreSequenceid ? diff : Long.compare(((KeyValue) r).getSequenceId(), ((KeyValue) l).getSequenceId());
}
private static int compareKeyValues(final KeyValue left, final KeyValue right) {
->>>>>>> rvv-optimization
int diff;
// Compare Rows. Cache row length.
int leftRowLength = left.getRowLength();
int rightRowLength = right.getRowLength();
diff = Bytes.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength,
-<<<<<<< HEAD
- right.getRowArray(), right.getRowOffset(), rightRowLength);
-=======
right.getRowArray(), right.getRowOffset(), rightRowLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
-<<<<<<< HEAD
- // If the column is not specified, the "minimum" key type appears as latest in the sorted
- // order, regardless of the timestamp. This is used for specifying the last key/value in a
- // given row, because there is no "lexicographically last column" (it would be infinitely
- // long).
- // The "maximum" key type does not need this behavior. Copied from KeyValue. This is bad in
-=======
// If the column is not specified, the "minimum" key type appears as latest in
// the sorted
// order, regardless of the timestamp. This is used for specifying the last
@@ -177,30 +131,18 @@ private static int compareKeyValues(final KeyValue left, final KeyValue right) {
// long).
// The "maximum" key type does not need this behavior. Copied from KeyValue.
// This is bad in
->>>>>>> rvv-optimization
// that
// we can't do memcmp w/ special rules like this.
// TODO: Is there a test for this behavior?
int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);
int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);
int leftKeyLength = left.getKeyLength();
-<<<<<<< HEAD
- int leftQualifierLength =
- left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
-=======
int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
->>>>>>> rvv-optimization
// No need of left row length below here.
byte leftType = left.getTypeByte(leftKeyLength);
-<<<<<<< HEAD
- if (
- leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0
- ) {
-=======
if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) {
->>>>>>> rvv-optimization
// left is "bigger", i.e. it appears later in the sorted order
return 1;
}
@@ -208,51 +150,29 @@ private static int compareKeyValues(final KeyValue left, final KeyValue right) {
int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);
int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);
int rightKeyLength = right.getKeyLength();
-<<<<<<< HEAD
- int rightQualifierLength =
- right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
-=======
int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
->>>>>>> rvv-optimization
// No need of right row length below here.
byte rightType = right.getTypeByte(rightKeyLength);
-<<<<<<< HEAD
- if (
- rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0
- ) {
-=======
if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) {
->>>>>>> rvv-optimization
return -1;
}
// Compare families.
int leftFamilyPosition = left.getFamilyOffset(leftFamilyLengthPosition);
int rightFamilyPosition = right.getFamilyOffset(rightFamilyLengthPosition);
-<<<<<<< HEAD
- diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition,
- rightFamilyLength);
-=======
diff = Bytes.compareTo(left.getFamilyArray(), leftFamilyPosition, leftFamilyLength,
right.getFamilyArray(), rightFamilyPosition, rightFamilyLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
// Compare qualifiers
diff = Bytes.compareTo(left.getQualifierArray(),
-<<<<<<< HEAD
- left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength,
- right.getQualifierArray(), right.getQualifierOffset(rightFamilyPosition, rightFamilyLength),
- rightQualifierLength);
-=======
left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength,
right.getQualifierArray(), right.getQualifierOffset(rightFamilyPosition, rightFamilyLength),
rightQualifierLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
@@ -272,32 +192,18 @@ private static int compareKeyValues(final KeyValue left, final KeyValue right) {
return (0xff & rightType) - (0xff & leftType);
}
-<<<<<<< HEAD
- private int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) {
-=======
private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) {
->>>>>>> rvv-optimization
int diff;
// Compare Rows. Cache row length.
int leftRowLength = left.getRowLength();
int rightRowLength = right.getRowLength();
diff = ByteBufferUtils.compareTo(left.getRowByteBuffer(), left.getRowPosition(), leftRowLength,
-<<<<<<< HEAD
- right.getRowByteBuffer(), right.getRowPosition(), rightRowLength);
-=======
right.getRowByteBuffer(), right.getRowPosition(), rightRowLength);
->>>>>>> rvv-optimization
+
if (diff != 0) {
return diff;
}
-<<<<<<< HEAD
- // If the column is not specified, the "minimum" key type appears as latest in the sorted
- // order, regardless of the timestamp. This is used for specifying the last key/value in a
- // given row, because there is no "lexicographically last column" (it would be infinitely
- // long).
- // The "maximum" key type does not need this behavior. Copied from KeyValue. This is bad in
-=======
// If the column is not specified, the "minimum" key type appears as latest in
// the sorted
// order, regardless of the timestamp. This is used for specifying the last
@@ -307,30 +213,18 @@ private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKe
// long).
// The "maximum" key type does not need this behavior. Copied from KeyValue.
// This is bad in
->>>>>>> rvv-optimization
// that
// we can't do memcmp w/ special rules like this.
// TODO: Is there a test for this behavior?
int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);
int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);
int leftKeyLength = left.getKeyLength();
-<<<<<<< HEAD
- int leftQualifierLength =
- left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
-=======
int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
->>>>>>> rvv-optimization
// No need of left row length below here.
byte leftType = left.getTypeByte(leftKeyLength);
-<<<<<<< HEAD
- if (
- leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0
- ) {
-=======
if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) {
->>>>>>> rvv-optimization
// left is "bigger", i.e. it appears later in the sorted order
return 1;
}
@@ -338,52 +232,29 @@ private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKe
int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);
int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);
int rightKeyLength = right.getKeyLength();
-<<<<<<< HEAD
- int rightQualifierLength =
- right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
-=======
int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
->>>>>>> rvv-optimization
// No need of right row length below here.
byte rightType = right.getTypeByte(rightKeyLength);
-<<<<<<< HEAD
- if (
- rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0
- ) {
-=======
if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) {
->>>>>>> rvv-optimization
return -1;
}
// Compare families.
int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition);
int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition);
-<<<<<<< HEAD
- diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition,
- rightFamilyLength);
-=======
- diff = ByteBufferUtils.compareToRvv(left.getFamilyByteBuffer(), leftFamilyPosition,
+ diff = RVVByteBufferUtils.compareToRvv(left.getFamilyByteBuffer(), leftFamilyPosition,
leftFamilyLength, right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
// Compare qualifiers
-<<<<<<< HEAD
- diff = ByteBufferUtils.compareTo(left.getQualifierByteBuffer(),
- left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength,
- right.getQualifierByteBuffer(),
- right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength);
-=======
- diff = ByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(),
+ diff = RVVByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(),
left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength,
right.getQualifierByteBuffer(),
right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
@@ -402,33 +273,17 @@ private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKe
return (0xff & rightType) - (0xff & leftType);
}
-<<<<<<< HEAD
- private int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) {
-=======
private static int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) {
->>>>>>> rvv-optimization
int diff;
// Compare Rows. Cache row length.
int leftRowLength = left.getRowLength();
int rightRowLength = right.getRowLength();
-<<<<<<< HEAD
- diff = ByteBufferUtils.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength,
- right.getRowByteBuffer(), right.getRowPosition(), rightRowLength);
-=======
- diff = ByteBufferUtils.compareToRvv(right.getRowByteBuffer(), right.getRowPosition(), rightRowLength,
+ diff = ByteBufferUtils.compareTo(right.getRowByteBuffer(), right.getRowPosition(), rightRowLength,
left.getRowArray(), left.getRowOffset(), leftRowLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
-<<<<<<< HEAD
- // If the column is not specified, the "minimum" key type appears as latest in the sorted
- // order, regardless of the timestamp. This is used for specifying the last key/value in a
- // given row, because there is no "lexicographically last column" (it would be infinitely
- // long).
- // The "maximum" key type does not need this behavior. Copied from KeyValue. This is bad in
-=======
// If the column is not specified, the "minimum" key type appears as latest in
// the sorted
// order, regardless of the timestamp. This is used for specifying the last
@@ -438,30 +293,18 @@ private static int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue
// long).
// The "maximum" key type does not need this behavior. Copied from KeyValue.
// This is bad in
->>>>>>> rvv-optimization
// that
// we can't do memcmp w/ special rules like this.
// TODO: Is there a test for this behavior?
int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);
int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);
int leftKeyLength = left.getKeyLength();
-<<<<<<< HEAD
- int leftQualifierLength =
- left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
-=======
int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
->>>>>>> rvv-optimization
// No need of left row length below here.
byte leftType = left.getTypeByte(leftKeyLength);
-<<<<<<< HEAD
- if (
- leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0
- ) {
-=======
if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) {
->>>>>>> rvv-optimization
// left is "bigger", i.e. it appears later in the sorted order
return 1;
}
@@ -469,52 +312,29 @@ private static int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue
int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);
int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);
int rightKeyLength = right.getKeyLength();
-<<<<<<< HEAD
- int rightQualifierLength =
- right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
-=======
int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
->>>>>>> rvv-optimization
// No need of right row length below here.
byte rightType = right.getTypeByte(rightKeyLength);
-<<<<<<< HEAD
- if (
- rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0
- ) {
-=======
if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) {
->>>>>>> rvv-optimization
return -1;
}
// Compare families.
int leftFamilyPosition = left.getFamilyOffset(leftFamilyLengthPosition);
int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition);
-<<<<<<< HEAD
- diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition,
- rightFamilyLength);
-=======
- diff = ByteBufferUtils.compareToRvv(right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength,
+ diff = ByteBufferUtils.compareTo(right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength,
left.getFamilyArray(), leftFamilyPosition, leftFamilyLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
// Compare qualifiers
-<<<<<<< HEAD
- diff = ByteBufferUtils.compareTo(left.getQualifierArray(),
- left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength,
- right.getQualifierByteBuffer(),
- right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength);
-=======
- diff = ByteBufferUtils.compareToRvv(right.getQualifierByteBuffer(),
+ diff = ByteBufferUtils.compareTo(right.getQualifierByteBuffer(),
right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength,
left.getQualifierArray(),
left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength);
->>>>>>> rvv-optimization
if (diff != 0) {
return diff;
}
@@ -535,13 +355,9 @@ private static int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue
/**
* Compares the family and qualifier part of the cell
-<<<<<<< HEAD
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
-=======
*
* @return 0 if both cells are equal, 1 if left cell is bigger than right, -1
* otherwise
->>>>>>> rvv-optimization
*/
public final int compareColumns(final Cell left, final Cell right) {
int diff = compareFamilies(left, right);
@@ -552,11 +368,7 @@ public final int compareColumns(final Cell left, final Cell right) {
}
private int compareColumns(final Cell left, final int leftFamLen, final int leftQualLen,
-<<<<<<< HEAD
- final Cell right, final int rightFamLen, final int rightQualLen) {
-=======
final Cell right, final int rightFamLen, final int rightQualLen) {
->>>>>>> rvv-optimization
int diff = compareFamilies(left, leftFamLen, right, rightFamLen);
if (diff != 0) {
return diff;
@@ -564,92 +376,41 @@ private int compareColumns(final Cell left, final int leftFamLen, final int left
return compareQualifiers(left, leftQualLen, right, rightQualLen);
}
-<<<<<<< HEAD
- /**
- * This method will be overridden when we compare cells inner store to bypass family comparing.
- */
- protected int compareFamilies(Cell left, int leftFamLen, Cell right, int rightFamLen) {
- if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) left).getFamilyPosition(), leftFamLen,
- ((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen);
- }
- if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) left).getFamilyPosition(), leftFamLen, right.getFamilyArray(),
- right.getFamilyOffset(), rightFamLen);
- }
- if (right instanceof ByteBufferExtendedCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
-=======
private int compareFamilies(Cell left, int leftFamLen, Cell right, int rightFamLen) {
if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
+ return RVVByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
((ByteBufferExtendedCell) left).getFamilyPosition(), leftFamLen,
((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen);
}
if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
((ByteBufferExtendedCell) left).getFamilyPosition(), leftFamLen, right.getFamilyArray(),
right.getFamilyOffset(), rightFamLen);
}
if (right instanceof ByteBufferExtendedCell) {
// Notice how we flip the order of the compare here. We used to negate the
// return value but
->>>>>>> rvv-optimization
// see what FindBugs says
// http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
// It suggest flipping the order to get same effect and 'safer'.
return ByteBufferUtils.compareTo(left.getFamilyArray(), left.getFamilyOffset(), leftFamLen,
-<<<<<<< HEAD
- ((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen);
- }
- return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), leftFamLen,
- right.getFamilyArray(), right.getFamilyOffset(), rightFamLen);
-=======
((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen);
}
return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), leftFamLen,
right.getFamilyArray(), right.getFamilyOffset(), rightFamLen);
->>>>>>> rvv-optimization
}
private final int compareQualifiers(Cell left, int leftQualLen, Cell right, int rightQualLen) {
if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
-<<<<<<< HEAD
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen,
- ((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) right).getQualifierPosition(), rightQualLen);
- }
- if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen,
- right.getQualifierArray(), right.getQualifierOffset(), rightQualLen);
- }
- if (right instanceof ByteBufferExtendedCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
- // see what FindBugs says
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
- // It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
- leftQualLen, ((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) right).getQualifierPosition(), rightQualLen);
- }
- return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(), leftQualLen,
- right.getQualifierArray(), right.getQualifierOffset(), rightQualLen);
-=======
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
+ return RVVByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen,
((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
((ByteBufferExtendedCell) right).getQualifierPosition(), rightQualLen);
}
if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen,
right.getQualifierArray(), right.getQualifierOffset(), rightQualLen);
}
@@ -659,91 +420,30 @@ private final int compareQualifiers(Cell left, int leftQualLen, Cell right, int
// see what FindBugs says
// http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
// It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
((ByteBufferExtendedCell) right).getQualifierPosition(), rightQualLen,
left.getQualifierArray(), left.getQualifierOffset(), leftQualLen);
}
return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(), leftQualLen,
right.getQualifierArray(), right.getQualifierOffset(), rightQualLen);
->>>>>>> rvv-optimization
}
/**
* Compare the families of left and right cell
-<<<<<<< HEAD
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
-=======
*
* @return 0 if both cells are equal, 1 if left cell is bigger than right, -1
* otherwise
->>>>>>> rvv-optimization
*/
@Override
public final int compareFamilies(Cell left, Cell right) {
if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
-<<<<<<< HEAD
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),
- ((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength());
- }
- if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),
- right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
- }
- if (right instanceof ByteBufferExtendedCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
- // see what FindBugs says
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
- // It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareTo(left.getFamilyArray(), left.getFamilyOffset(),
- left.getFamilyLength(), ((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
- ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength());
- }
- return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength(),
- right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
- }
-
- /**
- * This method will be overridden when we compare cells inner store to bypass family comparing.
- */
- protected int compareFamilies(KeyValue left, int leftFamilyPosition, int leftFamilyLength,
- KeyValue right, int rightFamilyPosition, int rightFamilyLength) {
- return Bytes.compareTo(left.getFamilyArray(), leftFamilyPosition, leftFamilyLength,
- right.getFamilyArray(), rightFamilyPosition, rightFamilyLength);
- }
-
- /**
- * This method will be overridden when we compare cells inner store to bypass family comparing.
- */
- protected int compareFamilies(ByteBufferKeyValue left, int leftFamilyPosition,
- int leftFamilyLength, ByteBufferKeyValue right, int rightFamilyPosition,
- int rightFamilyLength) {
- return ByteBufferUtils.compareTo(left.getFamilyByteBuffer(), leftFamilyPosition,
- leftFamilyLength, right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength);
- }
-
- /**
- * This method will be overridden when we compare cells inner store to bypass family comparing.
- */
- protected int compareFamilies(KeyValue left, int leftFamilyPosition, int leftFamilyLength,
- ByteBufferKeyValue right, int rightFamilyPosition, int rightFamilyLength) {
- return ByteBufferUtils.compareTo(left.getFamilyArray(), leftFamilyPosition, leftFamilyLength,
- right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength);
- }
-
- static int compareQualifiers(KeyValue left, KeyValue right) {
- // 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
-=======
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
+ return RVVByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),
((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength());
}
if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(),
((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(),
right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength());
}
@@ -753,7 +453,7 @@ static int compareQualifiers(KeyValue left, KeyValue right) {
// see what FindBugs says
// http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
// It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) right).getFamilyByteBuffer(),
((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength(),
left.getFamilyArray(), left.getFamilyOffset(), left.getFamilyLength());
}
@@ -766,7 +466,6 @@ static int compareQualifiers(KeyValue left, KeyValue right) {
// intentionally. Not
// sharing gets us a few percent more throughput in compares. If changes here or
// there, make
->>>>>>> rvv-optimization
// sure done in both places.
// Compare Rows. Cache row length.
int leftRowLength = left.getRowLength();
@@ -775,41 +474,21 @@ static int compareQualifiers(KeyValue left, KeyValue right) {
int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);
byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);
int leftKeyLength = left.getKeyLength();
-<<<<<<< HEAD
- int leftQualifierLength =
- left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
-=======
int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
->>>>>>> rvv-optimization
// No need of left row length below here.
int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);
byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);
int rightKeyLength = right.getKeyLength();
-<<<<<<< HEAD
- int rightQualifierLength =
- right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
-=======
int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
->>>>>>> rvv-optimization
// Compare families.
int leftFamilyOffset = left.getFamilyOffset(leftFamilyLengthPosition);
int rightFamilyOffset = right.getFamilyOffset(rightFamilyLengthPosition);
// Compare qualifiers
-<<<<<<< HEAD
return Bytes.compareTo(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength,
- leftQualifierLength, right.getQualifierArray(), rightFamilyOffset + rightFamilyLength,
- rightQualifierLength);
- }
-
- static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) {
- // 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
-=======
- return ByteBufferUtils.compareToRvv(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength,
leftQualifierLength, right.getQualifierArray(), rightFamilyOffset + rightFamilyLength,
rightQualifierLength);
}
@@ -819,7 +498,6 @@ static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) {
// intentionally. Not
// sharing gets us a few percent more throughput in compares. If changes here or
// there, make
->>>>>>> rvv-optimization
// sure done in both places.
// Compare Rows. Cache row length.
int leftRowLength = left.getRowLength();
@@ -828,41 +506,21 @@ static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) {
int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);
byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);
int leftKeyLength = left.getKeyLength();
-<<<<<<< HEAD
- int leftQualifierLength =
- left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
-=======
int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
->>>>>>> rvv-optimization
// No need of left row length below here.
int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);
byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);
int rightKeyLength = right.getKeyLength();
-<<<<<<< HEAD
- int rightQualifierLength =
- right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
-=======
int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
->>>>>>> rvv-optimization
// Compare families.
int leftFamilyOffset = left.getFamilyOffset(leftFamilyLengthPosition);
int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition);
// Compare qualifiers
-<<<<<<< HEAD
- return ByteBufferUtils.compareTo(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength,
- leftQualifierLength, right.getQualifierByteBuffer(), rightFamilyPosition + rightFamilyLength,
- rightQualifierLength);
- }
-
- static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) {
- // 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
-=======
- return ByteBufferUtils.compareToRvv(right.getQualifierByteBuffer(), rightFamilyPosition + rightFamilyLength,
+ return ByteBufferUtils.compareTo(right.getQualifierByteBuffer(), rightFamilyPosition + rightFamilyLength,
rightQualifierLength, left.getQualifierArray(), leftFamilyOffset + leftFamilyLength,
leftQualifierLength);
}
@@ -872,7 +530,6 @@ static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) {
// intentionally. Not
// sharing gets us a few percent more throughput in compares. If changes here or
// there, make
->>>>>>> rvv-optimization
// sure done in both places.
// Compare Rows. Cache row length.
int leftRowLength = left.getRowLength();
@@ -881,41 +538,21 @@ static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) {
int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);
byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);
int leftKeyLength = left.getKeyLength();
-<<<<<<< HEAD
- int leftQualifierLength =
- left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
-=======
int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
->>>>>>> rvv-optimization
// No need of left row length below here.
int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);
byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);
int rightKeyLength = right.getKeyLength();
-<<<<<<< HEAD
- int rightQualifierLength =
- right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
-=======
int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
->>>>>>> rvv-optimization
// Compare families.
int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition);
int rightFamilyOffset = right.getFamilyOffset(rightFamilyLengthPosition);
// Compare qualifiers
-<<<<<<< HEAD
return ByteBufferUtils.compareTo(left.getQualifierByteBuffer(),
- leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierArray(),
- rightFamilyOffset + rightFamilyLength, rightQualifierLength);
- }
-
- static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right) {
- // 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
-=======
- return ByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(),
leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierArray(),
rightFamilyOffset + rightFamilyLength, rightQualifierLength);
}
@@ -925,7 +562,6 @@ static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right)
// intentionally. Not
// sharing gets us a few percent more throughput in compares. If changes here or
// there, make
->>>>>>> rvv-optimization
// sure done in both places.
// Compare Rows. Cache row length.
int leftRowLength = left.getRowLength();
@@ -934,50 +570,30 @@ static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right)
int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength);
byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition);
int leftKeyLength = left.getKeyLength();
-<<<<<<< HEAD
- int leftQualifierLength =
- left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
-=======
int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength);
->>>>>>> rvv-optimization
// No need of left row length below here.
int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength);
byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition);
int rightKeyLength = right.getKeyLength();
-<<<<<<< HEAD
- int rightQualifierLength =
- right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
-=======
int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength);
->>>>>>> rvv-optimization
// Compare families.
int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition);
int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition);
// Compare qualifiers
-<<<<<<< HEAD
- return ByteBufferUtils.compareTo(left.getQualifierByteBuffer(),
- leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierByteBuffer(),
- rightFamilyPosition + rightFamilyLength, rightQualifierLength);
-=======
- return ByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(),
+ return RVVByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(),
leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierByteBuffer(),
rightFamilyPosition + rightFamilyLength, rightQualifierLength);
->>>>>>> rvv-optimization
}
/**
* Compare the qualifiers part of the left and right cells.
-<<<<<<< HEAD
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
-=======
*
* @return 0 if both cells are equal, 1 if left cell is bigger than right, -1
* otherwise
->>>>>>> rvv-optimization
*/
@Override
public final int compareQualifiers(Cell left, Cell right) {
@@ -991,37 +607,13 @@ public final int compareQualifiers(Cell left, Cell right) {
return compareQualifiers((ByteBufferKeyValue) left, (KeyValue) right);
} else {
if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
-<<<<<<< HEAD
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(),
- ((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) right).getQualifierPosition(), right.getQualifierLength());
- }
- if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(),
- right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength());
- }
- if (right instanceof ByteBufferExtendedCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
- // see what FindBugs says
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
- // It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
- left.getQualifierLength(), ((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
- ((ByteBufferExtendedCell) right).getQualifierPosition(), right.getQualifierLength());
- }
- return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
- left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),
- right.getQualifierLength());
-=======
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
+ return RVVByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(),
((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
((ByteBufferExtendedCell) right).getQualifierPosition(), right.getQualifierLength());
}
if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(),
((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(),
right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength());
}
@@ -1031,25 +623,18 @@ public final int compareQualifiers(Cell left, Cell right) {
// see what FindBugs says
// http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
// It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) right).getQualifierByteBuffer(),
((ByteBufferExtendedCell) right).getQualifierPosition(), right.getQualifierLength(),
left.getQualifierArray(), left.getQualifierOffset(), left.getQualifierLength());
}
return Bytes.compareTo(left.getQualifierArray(), left.getQualifierOffset(),
left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(),
right.getQualifierLength());
->>>>>>> rvv-optimization
}
}
/**
-<<<<<<< HEAD
- * Compares the rows of the left and right cell. For the hbase:meta case this method is overridden
- * such that it can handle hbase:meta cells. The caller should ensure using the appropriate
- * comparator for hbase:meta.
- * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 otherwise
-=======
* Compares the rows of the left and right cell. For the hbase:meta case this
* method is overridden
* such that it can handle hbase:meta cells. The caller should ensure using the
@@ -1058,7 +643,6 @@ public final int compareQualifiers(Cell left, Cell right) {
*
* @return 0 if both cells are equal, 1 if left cell is bigger than right, -1
* otherwise
->>>>>>> rvv-optimization
*/
@Override
public int compareRows(final Cell left, final Cell right) {
@@ -1071,44 +655,13 @@ static int compareRows(final Cell left, int leftRowLength, final Cell right, int
return 0;
}
if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
-<<<<<<< HEAD
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),
- ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength,
- ((ByteBufferExtendedCell) right).getRowByteBuffer(),
- ((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength);
- }
- if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),
- ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength, right.getRowArray(),
- right.getRowOffset(), rightRowLength);
- }
- if (right instanceof ByteBufferExtendedCell) {
- // Notice how we flip the order of the compare here. We used to negate the return value but
- // see what FindBugs says
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
- // It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength,
- ((ByteBufferExtendedCell) right).getRowByteBuffer(),
- ((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength);
- }
- return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength,
- right.getRowArray(), right.getRowOffset(), rightRowLength);
- }
-
- /**
- * Compares the row part of the cell with a simple plain byte[] like the stopRow in Scan. This
- * should be used with context where for hbase:meta cells the
- * {{@link MetaCellComparator#META_COMPARATOR} should be used the cell to be compared the kv
- * serialized byte[] to be compared with the offset in the byte[] the length in the byte[]
- * @return 0 if both cell and the byte[] are equal, 1 if the cell is bigger than byte[], -1
-=======
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getRowByteBuffer(),
+ return RVVByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getRowByteBuffer(),
((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength,
((ByteBufferExtendedCell) right).getRowByteBuffer(),
((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength);
}
if (left instanceof ByteBufferExtendedCell) {
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getRowByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),
((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength, right.getRowArray(),
right.getRowOffset(), rightRowLength);
}
@@ -1118,7 +671,7 @@ static int compareRows(final Cell left, int leftRowLength, final Cell right, int
// see what FindBugs says
// http://findbugs.sourceforge.net/bugDescriptions.html#RV_NEGATING_RESULT_OF_COMPARETO
// It suggest flipping the order to get same effect and 'safer'.
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) right).getRowByteBuffer(),
+ return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) right).getRowByteBuffer(),
((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength,
left.getRowArray(), left.getRowOffset(), leftRowLength);
}
@@ -1137,27 +690,17 @@ static int compareRows(final Cell left, int leftRowLength, final Cell right, int
*
* @return 0 if both cell and the byte[] are equal, 1 if the cell is bigger than
* byte[], -1
->>>>>>> rvv-optimization
* otherwise
*/
@Override
public int compareRows(Cell left, byte[] right, int roffset, int rlength) {
if (left instanceof ByteBufferExtendedCell) {
-<<<<<<< HEAD
return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(),
- ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right, roffset,
- rlength);
- }
- return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,
- roffset, rlength);
-=======
- return ByteBufferUtils.compareToRvv(((ByteBufferExtendedCell) left).getRowByteBuffer(),
((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right, roffset,
rlength);
}
return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,
roffset, rlength);
->>>>>>> rvv-optimization
}
@Override
@@ -1167,31 +710,17 @@ public final int compareWithoutRow(final Cell left, final Cell right) {
// for specifying the last key/value in a given row, because there is no
// "lexicographically last column" (it would be infinitely long). The
// "maximum" key type does not need this behavior.
-<<<<<<< HEAD
- // Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules like this.
-=======
// Copied from KeyValue. This is bad in that we can't do memcmp w/ special rules
// like this.
->>>>>>> rvv-optimization
int lFamLength = left.getFamilyLength();
int rFamLength = right.getFamilyLength();
int lQualLength = left.getQualifierLength();
int rQualLength = right.getQualifierLength();
-<<<<<<< HEAD
- byte leftType = PrivateCellUtil.getTypeByte(left);
- byte rightType = PrivateCellUtil.getTypeByte(right);
- if (lFamLength + lQualLength == 0 && leftType == KeyValue.Type.Minimum.getCode()) {
- // left is "bigger", i.e. it appears later in the sorted order
- return 1;
- }
- if (rFamLength + rQualLength == 0 && rightType == KeyValue.Type.Minimum.getCode()) {
-=======
- if (lFamLength + lQualLength == 0 && left.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
+ if (lFamLength + lQualLength == 0 && ((KeyValue) left).getTypeByte() == KeyValue.Type.Minimum.getCode()) {
// left is "bigger", i.e. it appears later in the sorted order
return 1;
}
- if (rFamLength + rQualLength == 0 && right.getTypeByte() == KeyValue.Type.Minimum.getCode()) {
->>>>>>> rvv-optimization
+ if (rFamLength + rQualLength == 0 && ((KeyValue) right).getTypeByte() == KeyValue.Type.Minimum.getCode()) {
return -1;
}
if (lFamLength != rFamLength) {
@@ -1213,11 +742,7 @@ public final int compareWithoutRow(final Cell left, final Cell right) {
// of higher numbers sort before those of lesser numbers. Maximum (255)
// appears ahead of everything, and minimum (0) appears after
// everything.
-<<<<<<< HEAD
- return (0xff & rightType) - (0xff & leftType);
-=======
- return (0xff & right.getTypeByte()) - (0xff & left.getTypeByte());
->>>>>>> rvv-optimization
+ return (0xff & ((KeyValue) right).getTypeByte()) - (0xff & ((KeyValue) left).getTypeByte());
}
@Override
@@ -1232,24 +757,15 @@ public int compareTimestamps(final long ltimestamp, final long rtimestamp) {
}
@Override
-<<<<<<< HEAD
public Comparator
- * The implementation is not thread safe. So there will be no race between next and close. The only
- * exception is updateReaders, it will be called in the memstore flush thread to indicate that there
+ * The implementation is not thread safe. So there will be no race between next
+ * and close. The only
+ * exception is updateReaders, it will be called in the memstore flush thread to
+ * indicate that there
* is a flush.
*/
@InterfaceAudience.Private
public class StoreScanner extends NonReversedNonLazyKeyValueScanner
- implements KeyValueScanner, InternalScanner, ChangedReadersObserver {
+ implements KeyValueScanner, InternalScanner, ChangedReadersObserver {
private static final Logger LOG = LoggerFactory.getLogger(StoreScanner.class);
// In unit tests, the store could be null
protected final HStore store;
@@ -125,38 +107,31 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
private final List
* Opens a scanner across specified StoreFiles.
+ *
* @param store who we scan
* @param scanners ancillary scanners
- * @param smallestReadPoint the readPoint that we should use for tracking versions
- * @param dropDeletesFromRow The inclusive left bound of the range; can be EMPTY_START_ROW.
- * @param dropDeletesToRow The exclusive right bound of the range; can be EMPTY_END_ROW.
+ * @param smallestReadPoint the readPoint that we should use for tracking
+ * versions
+ * @param dropDeletesFromRow The inclusive left bound of the range; can be
+ * EMPTY_START_ROW.
+ * @param dropDeletesToRow The exclusive right bound of the range; can be
+ * EMPTY_END_ROW.
*/
public StoreScanner(HStore store, ScanInfo scanInfo, List extends KeyValueScanner> scanners,
- long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow)
- throws IOException {
+ long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow)
+ throws IOException {
this(store, scanInfo, scanners, ScanType.COMPACT_RETAIN_DELETES, smallestReadPoint,
- earliestPutTs, dropDeletesFromRow, dropDeletesToRow);
+ earliestPutTs, dropDeletesFromRow, dropDeletesToRow);
}
private StoreScanner(HStore store, ScanInfo scanInfo, List extends KeyValueScanner> scanners,
- ScanType scanType, long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow,
- byte[] dropDeletesToRow) throws IOException {
+ ScanType scanType, long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow,
+ byte[] dropDeletesToRow) throws IOException {
this(store, SCAN_FOR_COMPACTION, scanInfo, 0,
- store.getHRegion().getReadPoint(IsolationLevel.READ_COMMITTED), false, scanType);
+ store.getHRegion().getReadPoint(IsolationLevel.READ_COMMITTED), false, scanType);
assert scanType != ScanType.USER_SCAN;
- matcher =
- CompactionScanQueryMatcher.create(scanInfo, scanType, smallestReadPoint, earliestPutTs,
+ matcher = CompactionScanQueryMatcher.create(scanInfo, scanType, smallestReadPoint, earliestPutTs,
oldestUnexpiredTS, now, dropDeletesFromRow, dropDeletesToRow, store.getCoprocessorHost());
// Filter the list of scanners using Bloom filters, time range, TTL, etc.
@@ -373,83 +361,57 @@ private StoreScanner(HStore store, ScanInfo scanInfo, List extends KeyValueSca
}
private void seekAllScanner(ScanInfo scanInfo, List extends KeyValueScanner> scanners)
- throws IOException {
+ throws IOException {
// Seek all scanners to the initial key
seekScanners(scanners, matcher.getStartKey(), false, parallelSeekEnabled);
addCurrentScanners(scanners);
resetKVHeap(scanners, comparator);
}
- // For mob compaction only as we do not have a Store instance when doing mob compaction.
+ // For mob compaction only as we do not have a Store instance when doing mob
+ // compaction.
public StoreScanner(ScanInfo scanInfo, ScanType scanType,
- List extends KeyValueScanner> scanners) throws IOException {
+ List extends KeyValueScanner> scanners) throws IOException {
this(null, SCAN_FOR_COMPACTION, scanInfo, 0, Long.MAX_VALUE, false, scanType);
assert scanType != ScanType.USER_SCAN;
this.matcher = CompactionScanQueryMatcher.create(scanInfo, scanType, Long.MAX_VALUE, 0L,
- oldestUnexpiredTS, now, null, null, null);
+ oldestUnexpiredTS, now, null, null, null);
seekAllScanner(scanInfo, scanners);
}
// Used to instantiate a scanner for user scan in test
StoreScanner(Scan scan, ScanInfo scanInfo, NavigableSet
* Other notes:
*
- * A good proxy (best effort) to determine whether SKIP is better than SEEK is whether we'll
- * likely end up seeking to the next block (or past the next block) to get our next column.
+ * A good proxy (best effort) to determine whether SKIP is better than SEEK is
+ * whether we'll
+ * likely end up seeking to the next block (or past the next block) to get our
+ * next column.
* Example:
*
*
*
*
@@ -1011,37 +919,32 @@ private void seekOrSkipToNextColumn(Cell cell) throws IOException {
* Next Index Key SEEK_NEXT_COL
*
*
- * Now imagine we want columns c1 and c3 (see first diagram above), the 'Next Index Key' of r1/c4
- * is > r1/c3 so we should seek to get to the c1 on the next row, r2. In second case, say we only
- * want one version of c1, after we have it, a SEEK_COL will be issued to get to c2. Looking at
- * the 'Next Index Key', it would land us in the next block, so we should SEEK. In other scenarios
- * where the SEEK will not land us in the next block, it is very likely better to issues a series
+ * Now imagine we want columns c1 and c3 (see first diagram above), the 'Next
+ * Index Key' of r1/c4
+ * is > r1/c3 so we should seek to get to the c1 on the next row, r2. In second
+ * case, say we only
+ * want one version of c1, after we have it, a SEEK_COL will be issued to get to
+ * c2. Looking at
+ * the 'Next Index Key', it would land us in the next block, so we should SEEK.
+ * In other scenarios
+ * where the SEEK will not land us in the next block, it is very likely better
+ * to issues a series
* of SKIPs.
+ *
* @param cell current cell
* @return true means skip to next row, false means not
*/
-<<<<<<< HEAD
protected boolean trySkipToNextRow(ExtendedCell cell) throws IOException {
ExtendedCell nextCell = null;
- // used to guard against a changed next indexed key by doing a identity comparison
+ // used to guard against a changed next indexed key by doing a identity
+ // comparison
// when the identity changes we need to compare the bytes again
ExtendedCell previousIndexedKey = null;
do {
ExtendedCell nextIndexedKey = getNextIndexedKey();
-=======
- protected boolean trySkipToNextRow(Cell cell) throws IOException {
- Cell nextCell = null;
- // used to guard against a changed next indexed key by doing a identity comparison
- // when the identity changes we need to compare the bytes again
- Cell previousIndexedKey = null;
- do {
- Cell nextIndexedKey = getNextIndexedKey();
->>>>>>> rvv-optimization
- if (
- nextIndexedKey != null && nextIndexedKey != KeyValueScanner.NO_NEXT_INDEXED_KEY
+ if (nextIndexedKey != null && nextIndexedKey != KeyValueScanner.NO_NEXT_INDEXED_KEY
&& (nextIndexedKey == previousIndexedKey
- || matcher.compareKeyForNextRow(nextIndexedKey, cell) >= 0)
- ) {
+ || matcher.compareKeyForNextRow(nextIndexedKey, cell) >= 0)) {
this.heap.next();
++kvsScanned;
previousIndexedKey = nextIndexedKey;
@@ -1053,36 +956,23 @@ protected boolean trySkipToNextRow(Cell cell) throws IOException {
}
/**
-<<<<<<< HEAD
- * See {@link #trySkipToNextRow(ExtendedCell)}
+ * See
+ * {@link org.apache.hadoop.hbase.regionserver.StoreScanner#trySkipToNextRow(Cell)}
+ *
* @param cell current cell
* @return true means skip to next column, false means not
*/
protected boolean trySkipToNextColumn(ExtendedCell cell) throws IOException {
ExtendedCell nextCell = null;
- // used to guard against a changed next indexed key by doing a identity comparison
+ // used to guard against a changed next indexed key by doing a identity
+ // comparison
// when the identity changes we need to compare the bytes again
ExtendedCell previousIndexedKey = null;
do {
ExtendedCell nextIndexedKey = getNextIndexedKey();
-=======
- * See {@link org.apache.hadoop.hbase.regionserver.StoreScanner#trySkipToNextRow(Cell)}
- * @param cell current cell
- * @return true means skip to next column, false means not
- */
- protected boolean trySkipToNextColumn(Cell cell) throws IOException {
- Cell nextCell = null;
- // used to guard against a changed next indexed key by doing a identity comparison
- // when the identity changes we need to compare the bytes again
- Cell previousIndexedKey = null;
- do {
- Cell nextIndexedKey = getNextIndexedKey();
->>>>>>> rvv-optimization
- if (
- nextIndexedKey != null && nextIndexedKey != KeyValueScanner.NO_NEXT_INDEXED_KEY
+ if (nextIndexedKey != null && nextIndexedKey != KeyValueScanner.NO_NEXT_INDEXED_KEY
&& (nextIndexedKey == previousIndexedKey
- || matcher.compareKeyForNextColumn(nextIndexedKey, cell) >= 0)
- ) {
+ || matcher.compareKeyForNextColumn(nextIndexedKey, cell) >= 0)) {
this.heap.next();
++kvsScanned;
previousIndexedKey = nextIndexedKey;
@@ -1091,15 +981,10 @@ protected boolean trySkipToNextColumn(Cell cell) throws IOException {
}
} while ((nextCell = this.heap.peek()) != null && CellUtil.matchingRowColumn(cell, nextCell));
// We need this check because it may happen that the new scanner that we get
- // during heap.next() is requiring reseek due of fake KV previously generated for
+ // during heap.next() is requiring reseek due of fake KV previously generated
+ // for
// ROWCOL bloom filter optimization. See HBASE-19863 for more details
-<<<<<<< HEAD
- if (
- useRowColBloom && nextCell != null && cell.getTimestamp() == PrivateConstants.OLDEST_TIMESTAMP
- ) {
-=======
- if (useRowColBloom && nextCell != null && cell.getTimestamp() == HConstants.OLDEST_TIMESTAMP) {
->>>>>>> rvv-optimization
+ if (useRowColBloom && nextCell != null && cell.getTimestamp() == PrivateConstants.OLDEST_TIMESTAMP) {
return false;
}
return true;
@@ -1123,7 +1008,7 @@ private static void clearAndClose(List