-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-24637 - Reseek regression related to filter SKIP hinting #2663
base: master
Are you sure you want to change the base?
Changes from 1 commit
8b286f2
31e0de3
e8029c3
4654078
974e6cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,9 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner | |
private Cell prevCell = null; | ||
|
||
private final long preadMaxBytes; | ||
private final long switchToNextOnlyBytes; | ||
private long bytesRead; | ||
private boolean seekToSameBlock; | ||
|
||
/** We don't ever expect to change this, the constant is just for clarity. */ | ||
static final boolean LAZY_SEEK_ENABLED_BY_DEFAULT = true; | ||
|
@@ -205,6 +207,9 @@ private StoreScanner(HStore store, Scan scan, ScanInfo scanInfo, | |
this.scanUsePread = this.readType != Scan.ReadType.STREAM; | ||
} | ||
this.preadMaxBytes = scanInfo.getPreadMaxBytes(); | ||
// TODO : Introduce config here at the ScanInfo level. Determine based on number of blocks | ||
// rather than bytes read? | ||
this.switchToNextOnlyBytes = this.preadMaxBytes; | ||
this.cellsPerHeartbeatCheck = scanInfo.getCellsPerTimeoutCheck(); | ||
// Parallel seeking is on if the config allows and more there is more than one store file. | ||
if (store != null && store.getStorefilesCount() > 1) { | ||
|
@@ -684,7 +689,7 @@ public boolean next(List<Cell> outResult, ScannerContext scannerContext) throws | |
matcher.clearCurrentRow(); | ||
seekOrSkipToNextRow(cell); | ||
} else if (qcode == ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL) { | ||
seekOrSkipToNextColumn(cell); | ||
doSeekCol(cell); | ||
} else { | ||
this.heap.next(); | ||
} | ||
|
@@ -728,7 +733,7 @@ public boolean next(List<Cell> outResult, ScannerContext scannerContext) throws | |
break; | ||
|
||
case SEEK_NEXT_COL: | ||
seekOrSkipToNextColumn(cell); | ||
doSeekCol(cell); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it is not need to change this method name? You can add the new logic to seekOrSkipToNextColumn method directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok . I can see how can that be done. |
||
NextState stateAfterSeekNextColumn = needToReturn(outResult); | ||
if (stateAfterSeekNextColumn != null) { | ||
return scannerContext.setScannerState(stateAfterSeekNextColumn).hasMoreValues(); | ||
|
@@ -786,6 +791,19 @@ private void updateMetricsStore(boolean memstoreRead) { | |
} | ||
} | ||
|
||
private void doSeekCol(Cell cell) throws IOException { | ||
// we check when ever a seek_next_col happens did the seek really land in a new block. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this comment helps with understanding. (It doesn't for me, but could just be me...) Questions to be answered by the comment:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// If the seek always lands in the same current block while trying to do a next, | ||
// we tend to go with next() rather than seek() based on the 'seekToSameBlock' | ||
// which is updated in the method 'seekOrSkipToNextColumn' | ||
if (seekToSameBlock && bytesRead > switchToNextOnlyBytes) { | ||
// forcefully make it to next only | ||
this.heap.next(); | ||
} else { | ||
seekOrSkipToNextColumn(cell); | ||
} | ||
} | ||
|
||
/** | ||
* If the top cell won't be flushed into disk, the new top cell may be | ||
* changed after #reopenAfterFlush. Because the older top cell only exist | ||
|
@@ -817,7 +835,13 @@ private void seekOrSkipToNextRow(Cell cell) throws IOException { | |
|
||
private void seekOrSkipToNextColumn(Cell cell) throws IOException { | ||
if (!trySkipToNextColumn(cell)) { | ||
boolean prevIndexKeyNull = (getNextIndexedKey() == null); | ||
seekAsDirection(matcher.getKeyForNextColumn(cell)); | ||
if (prevIndexKeyNull) { | ||
// even if one seek has lead to another block - reset to false. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment should be rewritten or removed. Ideally not removed, because you are trying to communicate something important for understanding how the code works. Try a rewrite? |
||
// TODO : For SEEK_NEXT_ROW also? | ||
seekToSameBlock = this.heap.isSeekToSameBlock(); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -1235,6 +1259,11 @@ public Cell getNextIndexedKey() { | |
return this.heap.getNextIndexedKey(); | ||
} | ||
|
||
@Override | ||
public boolean isSeekToSameBlock() { | ||
return this.heap.isSeekToSameBlock(); | ||
} | ||
|
||
@Override | ||
public void shipped() throws IOException { | ||
if (prevCell != null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be something deeply internal that no user could meaningfully set unless they read all the code and become a wizard. Please figure this out based on current configuration.
No new config!