HBASE-14227 Reduce the number of time row comparison is done in a Scan
(Ram)
This commit is contained in:
parent
90ca944e1b
commit
e32e4df780
|
@ -283,6 +283,7 @@ public class ScanQueryMatcher {
|
||||||
if (filter != null && filter.filterAllRemaining()) {
|
if (filter != null && filter.filterAllRemaining()) {
|
||||||
return MatchCode.DONE_SCAN;
|
return MatchCode.DONE_SCAN;
|
||||||
}
|
}
|
||||||
|
if (row != null) {
|
||||||
int ret = this.rowComparator.compareRows(row, this.rowOffset, this.rowLength,
|
int ret = this.rowComparator.compareRows(row, this.rowOffset, this.rowLength,
|
||||||
cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
|
cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
|
||||||
if (!this.isReversed) {
|
if (!this.isReversed) {
|
||||||
|
@ -301,6 +302,9 @@ public class ScanQueryMatcher {
|
||||||
return MatchCode.DONE;
|
return MatchCode.DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return MatchCode.DONE;
|
||||||
|
}
|
||||||
|
|
||||||
// optimize case.
|
// optimize case.
|
||||||
if (this.stickyNextRow)
|
if (this.stickyNextRow)
|
||||||
|
|
|
@ -491,8 +491,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
|
||||||
// If no limits exists in the scope LimitScope.Between_Cells then we are sure we are changing
|
// 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
|
// rows. Else it is possible we are still traversing the same row so we must perform the row
|
||||||
// comparison.
|
// comparison.
|
||||||
if (!scannerContext.hasAnyLimit(LimitScope.BETWEEN_CELLS) || matcher.row == null ||
|
if (!scannerContext.hasAnyLimit(LimitScope.BETWEEN_CELLS) || matcher.row == null) {
|
||||||
!Bytes.equals(row, offset, length, matcher.row, matcher.rowOffset, matcher.rowLength)) {
|
|
||||||
this.countPerRow = 0;
|
this.countPerRow = 0;
|
||||||
matcher.setRow(row, offset, length);
|
matcher.setRow(row, offset, length);
|
||||||
}
|
}
|
||||||
|
@ -540,6 +539,10 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
|
||||||
if (!matcher.moreRowsMayExistAfter(cell)) {
|
if (!matcher.moreRowsMayExistAfter(cell)) {
|
||||||
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
|
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
|
||||||
}
|
}
|
||||||
|
// Setting the matcher.row = null, will mean that after the subsequent seekToNextRow()
|
||||||
|
// 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.row = null;
|
||||||
seekToNextRow(cell);
|
seekToNextRow(cell);
|
||||||
break LOOP;
|
break LOOP;
|
||||||
}
|
}
|
||||||
|
@ -567,6 +570,10 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
|
||||||
if (!matcher.moreRowsMayExistAfter(cell)) {
|
if (!matcher.moreRowsMayExistAfter(cell)) {
|
||||||
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
|
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
|
||||||
}
|
}
|
||||||
|
// Setting the matcher.row = null, will mean that after the subsequent seekToNextRow()
|
||||||
|
// 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.row = null;
|
||||||
seekToNextRow(cell);
|
seekToNextRow(cell);
|
||||||
} else if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL) {
|
} else if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL) {
|
||||||
seekAsDirection(matcher.getKeyForNextColumn(cell));
|
seekAsDirection(matcher.getKeyForNextColumn(cell));
|
||||||
|
@ -583,6 +590,10 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case DONE:
|
case DONE:
|
||||||
|
// We are sure that this row is done and we are in the next row.
|
||||||
|
// So subsequent StoresScanner.next() call need not do another compare
|
||||||
|
// and set the matcher.row
|
||||||
|
matcher.row = null;
|
||||||
return scannerContext.setScannerState(NextState.MORE_VALUES).hasMoreValues();
|
return scannerContext.setScannerState(NextState.MORE_VALUES).hasMoreValues();
|
||||||
|
|
||||||
case DONE_SCAN:
|
case DONE_SCAN:
|
||||||
|
@ -595,7 +606,10 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
|
||||||
if (!matcher.moreRowsMayExistAfter(cell)) {
|
if (!matcher.moreRowsMayExistAfter(cell)) {
|
||||||
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
|
return scannerContext.setScannerState(NextState.NO_MORE_VALUES).hasMoreValues();
|
||||||
}
|
}
|
||||||
|
// Setting the matcher.row = null, will mean that after the subsequent seekToNextRow()
|
||||||
|
// 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.row = null;
|
||||||
seekToNextRow(cell);
|
seekToNextRow(cell);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue