hbase git commit: HBASE-17958 Avoid passing unexpected cell to ScanQueryMatcher when optimize SEEK to SKIP
Repository: hbase Updated Branches: refs/heads/branch-1 58c504e70 -> 9f25836d9 HBASE-17958 Avoid passing unexpected cell to ScanQueryMatcher when optimize SEEK to SKIP Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/9f25836d Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/9f25836d Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/9f25836d Branch: refs/heads/branch-1 Commit: 9f25836d99a7468a26bacb6a3009cf0fdc9736a8 Parents: 58c504e Author: Guanghao Zhang Authored: Tue May 2 16:52:06 2017 +0800 Committer: Guanghao Zhang Committed: Wed May 3 21:39:30 2017 +0800 -- .../java/org/apache/hadoop/hbase/CellUtil.java | 18 + .../hadoop/hbase/regionserver/StoreScanner.java | 107 +++--- .../querymatcher/LegacyScanQueryMatcher.java| 5 - .../querymatcher/ScanQueryMatcher.java | 8 - .../querymatcher/UserScanQueryMatcher.java | 6 - .../hbase/regionserver/TestStoreScanner.java| 381 ++- 6 files changed, 459 insertions(+), 66 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/9f25836d/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java -- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java index be50069..0290ded 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java @@ -475,6 +475,24 @@ public final class CellUtil { } /** + * Compares the row and column of two keyvalues for equality + * @param left + * @param right + * @return True if same row and column. + */ + public static boolean matchingRowColumn(final Cell left, final Cell right) { +if ((left.getRowLength() + left.getFamilyLength() + left.getQualifierLength()) != (right +.getRowLength() + right.getFamilyLength() + right.getQualifierLength())) { + return false; +} + +if (!matchingRow(left, right)) { + return false; +} +return matchingColumn(left, right); + } + + /** * @return True if a delete type, a {@link KeyValue.Type#Delete} or a * {KeyValue.Type#DeleteFamily} or a * {@link KeyValue.Type#DeleteColumn} KeyValue type. http://git-wip-us.apache.org/repos/asf/hbase/blob/9f25836d/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java index 28d9ef2..fa33326 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java @@ -539,7 +539,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner prevCell = cell; ScanQueryMatcher.MatchCode qcode = matcher.match(cell); - qcode = optimize(qcode, cell); switch (qcode) { case INCLUDE: case INCLUDE_AND_SEEK_NEXT_ROW: @@ -592,9 +591,9 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner // the heap.peek() will any way be in the next row. So the SQM.match(cell) need do // another compareRow to say the current row is DONE matcher.clearCurrentRow(); -seekToNextRow(cell); +seekOrSkipToNextRow(cell); } else if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL) { -seekAsDirection(matcher.getKeyForNextColumn(cell)); +seekOrSkipToNextColumn(cell); } else { this.heap.next(); } @@ -634,11 +633,11 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner // the heap.peek() will any way be in the next row. So the SQM.match(cell) need do // another compareRow to say the current row is DONE matcher.clearCurrentRow(); - seekToNextRow(cell); + seekOrSkipToNextRow(cell); break; case SEEK_NEXT_COL: - seekAsDirection(matcher.getKeyForNextColumn(cell)); + seekOrSkipToNextColumn(cell); break; case SKIP: @@ -668,35 +667,47 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues(); } + private void seekOrSkipToNextRow(Cell cell) throws IOException { +// If it is a Get Scan, then we know that we are done with this row; there are no more +// rows beyond t
hbase git commit: HBASE-17958 Avoid passing unexpected cell to ScanQueryMatcher when optimize SEEK to SKIP
Repository: hbase Updated Branches: refs/heads/master 4dbd025cc -> 91995749c HBASE-17958 Avoid passing unexpected cell to ScanQueryMatcher when optimize SEEK to SKIP Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/91995749 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/91995749 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/91995749 Branch: refs/heads/master Commit: 91995749c214135163d96316d915d2a084dfb690 Parents: 4dbd025 Author: Guanghao Zhang Authored: Thu Apr 27 14:07:21 2017 +0800 Committer: Guanghao Zhang Committed: Wed May 3 21:28:43 2017 +0800 -- .../hadoop/hbase/regionserver/StoreScanner.java | 108 +++-- .../querymatcher/LegacyScanQueryMatcher.java| 9 -- .../querymatcher/ScanQueryMatcher.java | 8 - .../querymatcher/UserScanQueryMatcher.java | 10 -- .../hbase/regionserver/TestStoreScanner.java| 161 +-- 5 files changed, 212 insertions(+), 84 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/91995749/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java index e42979e..d39a6ee 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java @@ -49,7 +49,6 @@ import org.apache.hadoop.hbase.regionserver.handler.ParallelSeekHandler; import org.apache.hadoop.hbase.regionserver.querymatcher.CompactionScanQueryMatcher; import org.apache.hadoop.hbase.regionserver.querymatcher.LegacyScanQueryMatcher; import org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher; -import org.apache.hadoop.hbase.regionserver.querymatcher.ScanQueryMatcher.MatchCode; import org.apache.hadoop.hbase.regionserver.querymatcher.UserScanQueryMatcher; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; @@ -572,7 +571,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner checkScanOrder(prevCell, cell, comparator); prevCell = cell; ScanQueryMatcher.MatchCode qcode = matcher.match(cell); - qcode = optimize(qcode, cell); switch (qcode) { case INCLUDE: case INCLUDE_AND_SEEK_NEXT_ROW: @@ -621,9 +619,9 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues(); } matcher.clearCurrentRow(); -seekToNextRow(cell); +seekOrSkipToNextRow(cell); } else if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL) { -seekAsDirection(matcher.getKeyForNextColumn(cell)); +seekOrSkipToNextColumn(cell); } else { this.heap.next(); } @@ -658,11 +656,11 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues(); } matcher.clearCurrentRow(); - seekToNextRow(cell); + seekOrSkipToNextRow(cell); break; case SEEK_NEXT_COL: - seekAsDirection(matcher.getKeyForNextColumn(cell)); + seekOrSkipToNextColumn(cell); break; case SKIP: @@ -692,35 +690,47 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues(); } + private void seekOrSkipToNextRow(Cell cell) throws IOException { +// If it is a Get Scan, then we know that we are done with this row; there are no more +// rows beyond the current one: don't try to optimize. +if (!get) { + if (trySkipToNextRow(cell)) { +return; + } +} +seekToNextRow(cell); + } + + private void seekOrSkipToNextColumn(Cell cell) throws IOException { +if (!trySkipToNextColumn(cell)) { + seekAsDirection(matcher.getKeyForNextColumn(cell)); +} + } + /** * See if we should actually SEEK or rather just SKIP to the next Cell (see HBASE-13109). - * This method works together with ColumnTrackers and Filters. ColumnTrackers may issue SEEK - * hints, such as seek to next column, next row, or seek to an arbitrary seek key. - * This method intercepts these qcodes and decides whether a seek is the most efficient _actual_ - * way to get us to the requested cell (SEEKs are more expensive than SKIP, SKIP, SKIP inside the - * current, loaded block). +