You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2016/01/06 06:09:07 UTC
hbase git commit: HBASE-14221 Reduce the number of time row
comparison is done in a Scan (Ram)
Repository: hbase
Updated Branches:
refs/heads/master 7cd09bfb9 -> 073e00c00
HBASE-14221 Reduce the number of time row comparison is done in a Scan
(Ram)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/073e00c0
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/073e00c0
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/073e00c0
Branch: refs/heads/master
Commit: 073e00c0053cb351dbba265112a6e756c932f875
Parents: 7cd09bf
Author: ramkrishna <ra...@gmail.com>
Authored: Wed Jan 6 10:38:27 2016 +0530
Committer: ramkrishna <ra...@gmail.com>
Committed: Wed Jan 6 10:38:27 2016 +0530
----------------------------------------------------------------------
.../hbase/regionserver/ScanQueryMatcher.java | 36 ++++++++++++--------
.../hadoop/hbase/regionserver/StoreScanner.java | 11 +++---
2 files changed, 27 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/073e00c0/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
index 47d8c8f..c220b5c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
@@ -283,27 +283,33 @@ public class ScanQueryMatcher {
if (filter != null && filter.filterAllRemaining()) {
return MatchCode.DONE_SCAN;
}
- int ret = this.rowComparator.compareRows(curCell, cell);
- if (!this.isReversed) {
- if (ret <= -1) {
- return MatchCode.DONE;
- } else if (ret >= 1) {
- // could optimize this, if necessary?
- // Could also be called SEEK_TO_CURRENT_ROW, but this
- // should be rare/never happens.
- return MatchCode.SEEK_NEXT_ROW;
+ if (curCell != null) {
+ int ret = this.rowComparator.compareRows(curCell, cell);
+ if (!this.isReversed) {
+ if (ret <= -1) {
+ return MatchCode.DONE;
+ } else if (ret >= 1) {
+ // could optimize this, if necessary?
+ // Could also be called SEEK_TO_CURRENT_ROW, but this
+ // should be rare/never happens.
+ return MatchCode.SEEK_NEXT_ROW;
+ }
+ } else {
+ if (ret <= -1) {
+ return MatchCode.SEEK_NEXT_ROW;
+ } else if (ret >= 1) {
+ return MatchCode.DONE;
+ }
}
} else {
- if (ret <= -1) {
- return MatchCode.SEEK_NEXT_ROW;
- } else if (ret >= 1) {
- return MatchCode.DONE;
- }
+ // Since the curCell is null it means we are already sure that we have moved over to the next row
+ return MatchCode.DONE;
}
// optimize case.
- if (this.stickyNextRow)
+ if (this.stickyNextRow) {
return MatchCode.SEEK_NEXT_ROW;
+ }
if (this.columns.done()) {
stickyNextRow = true;
http://git-wip-us.apache.org/repos/asf/hbase/blob/073e00c0/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 5fdfa79..3049608 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
@@ -507,8 +507,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
// If no limits exists in the scope LimitScope.Between_Cells then we are sure we are changing
// rows. Else it is possible we are still traversing the same row so we must perform the row
// comparison.
- if (!scannerContext.hasAnyLimit(LimitScope.BETWEEN_CELLS) || matcher.curCell == null
- || !CellUtil.matchingRow(cell, matcher.curCell)) {
+ if (!scannerContext.hasAnyLimit(LimitScope.BETWEEN_CELLS) || matcher.curCell == null) {
this.countPerRow = 0;
matcher.setToNewRow(cell);
}
@@ -534,7 +533,6 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
if (prevCell != cell) ++kvsScanned; // Do object compare - we set prevKV from the same heap.
checkScanOrder(prevCell, cell, comparator);
prevCell = cell;
-
ScanQueryMatcher.MatchCode qcode = matcher.match(cell);
qcode = optimize(qcode, cell);
switch (qcode) {
@@ -553,6 +551,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
if (!matcher.moreRowsMayExistAfter(cell)) {
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
}
+ matcher.curCell = null;
seekToNextRow(cell);
break LOOP;
}
@@ -580,6 +579,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
if (!matcher.moreRowsMayExistAfter(cell)) {
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
}
+ matcher.curCell = null;
seekToNextRow(cell);
} else if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL) {
seekAsDirection(matcher.getKeyForNextColumn(cell));
@@ -596,6 +596,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
continue;
case DONE:
+ matcher.curCell = null;
return scannerContext.setScannerState(NextState.MORE_VALUES).hasMoreValues();
case DONE_SCAN:
@@ -608,7 +609,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
if (!matcher.moreRowsMayExistAfter(cell)) {
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
}
-
+ matcher.curCell = null;
seekToNextRow(cell);
break;
@@ -751,7 +752,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
}
if ((matcher.curCell == null) || !CellUtil.matchingRows(cell, matcher.curCell)) {
this.countPerRow = 0;
- matcher.reset();
+ // The setToNewRow will call reset internally
matcher.setToNewRow(cell);
}
}