diff --git a/fix_remaining_conflicts.ps1 b/fix_remaining_conflicts.ps1
new file mode 100644
index 000000000000..d2928cad0577
--- /dev/null
+++ b/fix_remaining_conflicts.ps1
@@ -0,0 +1,19 @@
+# 修复剩余的Git合并冲突
+$filePath = "hbase-common\src\main\java\org\apache\hadoop\hbase\CellComparatorImpl.java"
+$content = Get-Content $filePath -Raw
+
+# 修复所有剩余的冲突模式
+$content = $content -replace '<<<<<<< HEAD\s*\n\s*private int compareBBKV\(final ByteBufferKeyValue left, final ByteBufferKeyValue right\) \{\s*\n=======\s*\n\s*private static int compareBBKV\(final ByteBufferKeyValue left, final ByteBufferKeyValue right\) \{\s*\n>>>>>>> rvv-optimization', 'private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) {'
+
+$content = $content -replace '<<<<<<< HEAD\s*\n\s*private int compareKVVsBBKV\(final KeyValue left, final ByteBufferKeyValue right\) \{\s*\n=======\s*\n\s*private static int compareKVVsBBKV\(final KeyValue left, final ByteBufferKeyValue right\) \{\s*\n>>>>>>> rvv-optimization', 'private static int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) {'
+
+# 修复方法调用冲突
+$content = $content -replace '<<<<<<< HEAD\s*\n\s*diff = ByteBufferUtils\.compareTo\(left\.getRowByteBuffer\(\), left\.getRowPosition\(\), leftRowLength,\s*\n\s*right\.getRowByteBuffer\(\), right\.getRowPosition\(\), rightRowLength\);\s*\n=======\s*\n\s*diff = ByteBufferUtils\.compareToRvv\(left\.getRowByteBuffer\(\), left\.getRowPosition\(\), leftRowLength,\s*\n\s*right\.getRowByteBuffer\(\), right\.getRowPosition\(\), rightRowLength\);\s*\n>>>>>>> rvv-optimization', 'diff = ByteBufferUtils.compareToRvv(left.getRowByteBuffer(), left.getRowPosition(), leftRowLength, right.getRowByteBuffer(), right.getRowPosition(), rightRowLength);'
+
+# 修复其他常见的冲突模式
+$content = $content -replace '<<<<<<< HEAD\s*\n\s*.*?\s*\n=======\s*\n\s*(.*?)\s*\n>>>>>>> rvv-optimization', '$1'
+
+# 保存文件
+Set-Content $filePath $content -Encoding UTF8
+
+Write-Host "冲突修复完成!"
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..ab51983098bb 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
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -22,25 +22,34 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
+import org.apache.hadoop.hbase.util.RVVByteBufferUtils;
/**
- * 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
+ * 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 + * 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. + * 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") +@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") @InterfaceAudience.Private @InterfaceStability.Evolving public class CellComparatorImpl implements CellComparator { @@ -48,7 +57,8 @@ public class CellComparatorImpl implements CellComparator { private static final long serialVersionUID = 8186411895799094989L; /** - * 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 * KeyValue only. */ public static final CellComparatorImpl COMPARATOR = new CellComparatorImpl(); @@ -96,45 +106,43 @@ public int compare(final Cell l, final Cell r, boolean ignoreSequenceid) { return diff; } } - - 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)); + // Negate following comparisons so later edits show up first mvccVersion: later + // sorts first + return ignoreSequenceid ? diff : Long.compare(((KeyValue) r).getSequenceId(), ((KeyValue) l).getSequenceId()); } - private int compareKeyValues(final KeyValue left, final KeyValue right) { + private static int compareKeyValues(final KeyValue left, final KeyValue right) { int diff; // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); diff = Bytes.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength, - right.getRowArray(), right.getRowOffset(), rightRowLength); + right.getRowArray(), right.getRowOffset(), rightRowLength); if (diff != 0) { return diff; } - // 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 + // 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 + // The "maximum" key type does not need this behavior. Copied from KeyValue. + // This is bad in // 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(); - int leftQualifierLength = - left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); // No need of left row length below here. byte leftType = left.getTypeByte(leftKeyLength); - if ( - leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0 - ) { + if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) { // left is "bigger", i.e. it appears later in the sorted order return 1; } @@ -142,32 +150,29 @@ private int compareKeyValues(final KeyValue left, final KeyValue right) { int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); - int rightQualifierLength = - right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); // No need of right row length below here. byte rightType = right.getTypeByte(rightKeyLength); - if ( - rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0 - ) { + if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) { return -1; } // Compare families. int leftFamilyPosition = left.getFamilyOffset(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyOffset(rightFamilyLengthPosition); - diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition, - rightFamilyLength); + diff = Bytes.compareTo(left.getFamilyArray(), leftFamilyPosition, leftFamilyLength, + right.getFamilyArray(), rightFamilyPosition, rightFamilyLength); if (diff != 0) { return diff; } // Compare qualifiers diff = Bytes.compareTo(left.getQualifierArray(), - left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength, - right.getQualifierArray(), right.getQualifierOffset(rightFamilyPosition, rightFamilyLength), - rightQualifierLength); + left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength, + right.getQualifierArray(), right.getQualifierOffset(rightFamilyPosition, rightFamilyLength), + rightQualifierLength); if (diff != 0) { return diff; } @@ -187,37 +192,39 @@ private int compareKeyValues(final KeyValue left, final KeyValue right) { return (0xff & rightType) - (0xff & leftType); } - private int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) { + private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) { int diff; // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); diff = ByteBufferUtils.compareTo(left.getRowByteBuffer(), left.getRowPosition(), leftRowLength, - right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); + right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); + if (diff != 0) { return diff; } - // 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 + // 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 + // The "maximum" key type does not need this behavior. Copied from KeyValue. + // This is bad in // 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(); - int leftQualifierLength = - left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); // No need of left row length below here. byte leftType = left.getTypeByte(leftKeyLength); - if ( - leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0 - ) { + if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) { // left is "bigger", i.e. it appears later in the sorted order return 1; } @@ -225,32 +232,29 @@ private int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); - int rightQualifierLength = - right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); // No need of right row length below here. byte rightType = right.getTypeByte(rightKeyLength); - if ( - rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0 - ) { + if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) { return -1; } // Compare families. int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); - diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition, - rightFamilyLength); + diff = RVVByteBufferUtils.compareToRvv(left.getFamilyByteBuffer(), leftFamilyPosition, + leftFamilyLength, right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength); if (diff != 0) { return diff; } // Compare qualifiers - diff = ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), - left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength, - right.getQualifierByteBuffer(), - right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); + diff = RVVByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(), + left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength, + right.getQualifierByteBuffer(), + right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); if (diff != 0) { return diff; } @@ -269,37 +273,38 @@ private int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue return (0xff & rightType) - (0xff & leftType); } - private int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) { + private static int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) { int diff; // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); - diff = ByteBufferUtils.compareTo(left.getRowArray(), left.getRowOffset(), leftRowLength, - right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); + diff = ByteBufferUtils.compareTo(right.getRowByteBuffer(), right.getRowPosition(), rightRowLength, + left.getRowArray(), left.getRowOffset(), leftRowLength); if (diff != 0) { return diff; } - // 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 + // 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 + // The "maximum" key type does not need this behavior. Copied from KeyValue. + // This is bad in // 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(); - int leftQualifierLength = - left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); // No need of left row length below here. byte leftType = left.getTypeByte(leftKeyLength); - if ( - leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0 - ) { + if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) { // left is "bigger", i.e. it appears later in the sorted order return 1; } @@ -307,32 +312,29 @@ private int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); - int rightQualifierLength = - right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); // No need of right row length below here. byte rightType = right.getTypeByte(rightKeyLength); - if ( - rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0 - ) { + if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) { return -1; } // Compare families. int leftFamilyPosition = left.getFamilyOffset(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); - diff = compareFamilies(left, leftFamilyPosition, leftFamilyLength, right, rightFamilyPosition, - rightFamilyLength); + diff = ByteBufferUtils.compareTo(right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength, + left.getFamilyArray(), leftFamilyPosition, leftFamilyLength); if (diff != 0) { return diff; } // Compare qualifiers - diff = ByteBufferUtils.compareTo(left.getQualifierArray(), - left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength, - right.getQualifierByteBuffer(), - right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); + diff = ByteBufferUtils.compareTo(right.getQualifierByteBuffer(), + right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength, + left.getQualifierArray(), + left.getQualifierOffset(leftFamilyPosition, leftFamilyLength), leftQualifierLength); if (diff != 0) { return diff; } @@ -353,7 +355,9 @@ private int compareKVVsBBKV(final KeyValue left, final ByteBufferKeyValue right) /** * Compares the family and qualifier part of the cell - * @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 */ public final int compareColumns(final Cell left, final Cell right) { int diff = compareFamilies(left, right); @@ -364,7 +368,7 @@ public final int compareColumns(final Cell left, final Cell right) { } private int compareColumns(final Cell left, final int leftFamLen, final int leftQualLen, - final Cell right, final int rightFamLen, final int rightQualLen) { + final Cell right, final int rightFamLen, final int rightQualLen) { int diff = compareFamilies(left, leftFamLen, right, rightFamLen); if (diff != 0) { return diff; @@ -372,120 +376,96 @@ private int compareColumns(final Cell left, final int leftFamLen, final int left return compareQualifiers(left, leftQualLen, right, rightQualLen); } - /** - * 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) { + private 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); + return RVVByteBufferUtils.compareToRvv(((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); + ((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 + // 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(), leftFamLen, - ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), - ((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen); + ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), + ((ByteBufferExtendedCell) right).getFamilyPosition(), rightFamLen); } return Bytes.compareTo(left.getFamilyArray(), left.getFamilyOffset(), leftFamLen, - right.getFamilyArray(), right.getFamilyOffset(), rightFamLen); + right.getFamilyArray(), right.getFamilyOffset(), rightFamLen); } private final int compareQualifiers(Cell left, int leftQualLen, Cell right, int rightQualLen) { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { - return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), - ((ByteBufferExtendedCell) left).getQualifierPosition(), leftQualLen, - ((ByteBufferExtendedCell) right).getQualifierByteBuffer(), - ((ByteBufferExtendedCell) right).getQualifierPosition(), rightQualLen); + return RVVByteBufferUtils.compareToRvv(((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); + ((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 + // 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 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); + right.getQualifierArray(), right.getQualifierOffset(), rightQualLen); } /** * Compare the families of left and right cell - * @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 */ @Override public final int compareFamilies(Cell left, Cell right) { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { - return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(), - ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(), - ((ByteBufferExtendedCell) right).getFamilyByteBuffer(), - ((ByteBufferExtendedCell) right).getFamilyPosition(), right.getFamilyLength()); + 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.compareTo(((ByteBufferExtendedCell) left).getFamilyByteBuffer(), - ((ByteBufferExtendedCell) left).getFamilyPosition(), left.getFamilyLength(), - right.getFamilyArray(), right.getFamilyOffset(), right.getFamilyLength()); + ((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 + // 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 ByteBufferUtils.compareTo(((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()); - } - - /** - * 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); + 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 + // NOTE: Same method is in CellComparatorImpl, also private, not shared, + // intentionally. Not + // sharing gets us a few percent more throughput in compares. If changes here or + // there, make // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -494,16 +474,14 @@ static int compareQualifiers(KeyValue left, KeyValue right) { int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); - int leftQualifierLength = - left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); - int rightQualifierLength = - right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); // Compare families. int leftFamilyOffset = left.getFamilyOffset(leftFamilyLengthPosition); @@ -511,13 +489,15 @@ static int compareQualifiers(KeyValue left, KeyValue right) { // Compare qualifiers return Bytes.compareTo(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength, - leftQualifierLength, right.getQualifierArray(), rightFamilyOffset + rightFamilyLength, - rightQualifierLength); + 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 + // NOTE: Same method is in CellComparatorImpl, also private, not shared, + // intentionally. Not + // sharing gets us a few percent more throughput in compares. If changes here or + // there, make // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -526,30 +506,30 @@ static int compareQualifiers(KeyValue left, ByteBufferKeyValue right) { int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); - int leftQualifierLength = - left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); - int rightQualifierLength = - right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); // Compare families. int leftFamilyOffset = left.getFamilyOffset(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); // Compare qualifiers - return ByteBufferUtils.compareTo(left.getQualifierArray(), leftFamilyOffset + leftFamilyLength, - leftQualifierLength, right.getQualifierByteBuffer(), rightFamilyPosition + rightFamilyLength, - rightQualifierLength); + return ByteBufferUtils.compareTo(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 + // NOTE: Same method is in CellComparatorImpl, also private, not shared, + // intentionally. Not + // sharing gets us a few percent more throughput in compares. If changes here or + // there, make // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -558,16 +538,14 @@ static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) { int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); - int leftQualifierLength = - left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); - int rightQualifierLength = - right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); // Compare families. int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); @@ -575,13 +553,15 @@ static int compareQualifiers(ByteBufferKeyValue left, KeyValue right) { // Compare qualifiers return ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), - leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierArray(), - rightFamilyOffset + rightFamilyLength, rightQualifierLength); + 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 + // NOTE: Same method is in CellComparatorImpl, also private, not shared, + // intentionally. Not + // sharing gets us a few percent more throughput in compares. If changes here or + // there, make // sure done in both places. // Compare Rows. Cache row length. int leftRowLength = left.getRowLength(); @@ -590,30 +570,30 @@ static int compareQualifiers(ByteBufferKeyValue left, ByteBufferKeyValue right) int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); byte leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); - int leftQualifierLength = - left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); + int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); // No need of left row length below here. int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); byte rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); - int rightQualifierLength = - right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); + int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); // Compare families. int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); // Compare qualifiers - return ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), - leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierByteBuffer(), - rightFamilyPosition + rightFamilyLength, rightQualifierLength); + return RVVByteBufferUtils.compareToRvv(left.getQualifierByteBuffer(), + leftFamilyPosition + leftFamilyLength, leftQualifierLength, right.getQualifierByteBuffer(), + rightFamilyPosition + rightFamilyLength, rightQualifierLength); } /** * Compare the qualifiers part of the left and right cells. - * @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 */ @Override public final int compareQualifiers(Cell left, Cell right) { @@ -627,37 +607,42 @@ public final int compareQualifiers(Cell left, Cell right) { return compareQualifiers((ByteBufferKeyValue) left, (KeyValue) right); } else { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { - return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), - ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(), - ((ByteBufferExtendedCell) right).getQualifierByteBuffer(), - ((ByteBufferExtendedCell) right).getQualifierPosition(), right.getQualifierLength()); + 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.compareTo(((ByteBufferExtendedCell) left).getQualifierByteBuffer(), - ((ByteBufferExtendedCell) left).getQualifierPosition(), left.getQualifierLength(), - right.getQualifierArray(), right.getQualifierOffset(), right.getQualifierLength()); + ((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 + // 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 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()); + left.getQualifierLength(), right.getQualifierArray(), right.getQualifierOffset(), + right.getQualifierLength()); } } /** - * 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 + * 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 + * + * @return 0 if both cells are equal, 1 if left cell is bigger than right, -1 + * otherwise */ @Override public int compareRows(final Cell left, final Cell right) { @@ -670,46 +655,52 @@ static int compareRows(final Cell left, int leftRowLength, final Cell right, int return 0; } if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { - return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(), - ((ByteBufferExtendedCell) left).getRowPosition(), leftRowLength, - ((ByteBufferExtendedCell) right).getRowByteBuffer(), - ((ByteBufferExtendedCell) right).getRowPosition(), rightRowLength); + return RVVByteBufferUtils.compareToRvv(((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); + ((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 + // 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 ByteBufferUtils.compareTo(((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); + right.getRowArray(), right.getRowOffset(), rightRowLength); } /** - * Compares the row part of the cell with a simple plain byte[] like the stopRow in Scan. This + * 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 + * {{@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 * otherwise */ @Override public int compareRows(Cell left, byte[] right, int roffset, int rlength) { if (left instanceof ByteBufferExtendedCell) { return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getRowByteBuffer(), - ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right, roffset, - rlength); + ((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(), right, roffset, + rlength); } return Bytes.compareTo(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right, - roffset, rlength); + roffset, rlength); } @Override @@ -719,18 +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. - // 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. int lFamLength = left.getFamilyLength(); int rFamLength = right.getFamilyLength(); int lQualLength = left.getQualifierLength(); int rQualLength = right.getQualifierLength(); - byte leftType = PrivateCellUtil.getTypeByte(left); - byte rightType = PrivateCellUtil.getTypeByte(right); - if (lFamLength + lQualLength == 0 && leftType == 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 && rightType == KeyValue.Type.Minimum.getCode()) { + if (rFamLength + rQualLength == 0 && ((KeyValue) right).getTypeByte() == KeyValue.Type.Minimum.getCode()) { return -1; } if (lFamLength != rFamLength) { @@ -752,7 +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. - return (0xff & rightType) - (0xff & leftType); + return (0xff & ((KeyValue) right).getTypeByte()) - (0xff & ((KeyValue) left).getTypeByte()); } @Override @@ -772,8 +762,10 @@ 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;
@@ -109,7 +107,8 @@ 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.
@@ -345,58 +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:
*
*
*
*
@@ -907,27 +919,32 @@ private void seekOrSkipToNextColumn(ExtendedCell 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
*/
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();
- 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;
@@ -939,22 +956,23 @@ protected boolean trySkipToNextRow(ExtendedCell cell) throws IOException {
}
/**
- * 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();
- 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;
@@ -963,11 +981,10 @@ protected boolean trySkipToNextColumn(ExtendedCell 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
- if (
- useRowColBloom && nextCell != null && cell.getTimestamp() == PrivateConstants.OLDEST_TIMESTAMP
- ) {
+ if (useRowColBloom && nextCell != null && cell.getTimestamp() == PrivateConstants.OLDEST_TIMESTAMP) {
return false;
}
return true;
@@ -991,7 +1008,7 @@ private static void clearAndClose(List