@InterfaceAudience.Private public class StoreScanner extends NonReversedNonLazyKeyValueScanner implements KeyValueScanner, InternalScanner, ChangedReadersObserver
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.
Modifier and Type | Field and Description |
---|---|
private long |
bytesRead |
private boolean |
cacheBlocks |
private long |
cellsPerHeartbeatCheck |
private ReentrantLock |
closeLock |
private boolean |
closing |
private CellComparator |
comparator |
private long |
countPerRow |
(package private) List<KeyValueScanner> |
currentScanners |
static long |
DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
Default value of
HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK . |
private ExecutorService |
executor |
private boolean |
explicitColumnQuery |
private boolean |
flushed |
private List<KeyValueScanner> |
flushedstoreFileScanners |
private ReentrantLock |
flushLock |
private boolean |
get |
static String |
HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
The number of cells scanned in between timeout checks.
|
protected KeyValueHeap |
heap |
private long |
kvsScanned
The number of KVs seen by the scanner.
|
(package private) static boolean |
LAZY_SEEK_ENABLED_BY_DEFAULT
We don't ever expect to change this, the constant is just for clarity.
|
private static boolean |
lazySeekEnabledGlobally
Used during unit testing to ensure that lazy seek does save seek ops
|
private static org.slf4j.Logger |
LOG |
private ScanQueryMatcher |
matcher |
private long |
maxRowSize |
(package private) long |
memstoreOnlyReads |
private List<KeyValueScanner> |
memStoreScannersAfterFlush |
private int |
minVersions |
(package private) long |
mixedReads |
private long |
now |
private long |
oldestUnexpiredTS |
private boolean |
parallelSeekEnabled
A flag that enables StoreFileScanner parallel-seeking
|
private long |
preadMaxBytes |
private Cell |
prevCell |
protected long |
readPt |
private Scan.ReadType |
readType |
private Scan |
scan |
private static Scan |
SCAN_FOR_COMPACTION |
private List<KeyValueScanner> |
scannersForDelayedClose |
private boolean |
scanUsePread |
protected HStore |
store |
private int |
storeLimit |
private int |
storeOffset |
static String |
STORESCANNER_PARALLEL_SEEK_ENABLE |
static String |
STORESCANNER_PREAD_MAX_BYTES
If the read type is Scan.ReadType.DEFAULT, we will start with pread, and if the kvs we scanned
reaches this limit, we will reopen the scanner with stream.
|
private boolean |
topChanged |
private boolean |
useRowColBloom |
NO_NEXT_INDEXED_KEY
Modifier | Constructor and Description |
---|---|
|
StoreScanner(HStore store,
ScanInfo scanInfo,
List<? extends KeyValueScanner> scanners,
long smallestReadPoint,
long earliestPutTs,
byte[] dropDeletesFromRow,
byte[] dropDeletesToRow)
Used for compactions that drop deletes from a limited range of rows.
|
|
StoreScanner(HStore store,
ScanInfo scanInfo,
List<? extends KeyValueScanner> scanners,
ScanType scanType,
long smallestReadPoint,
long earliestPutTs)
Used for store file compaction and memstore compaction.
|
private |
StoreScanner(HStore store,
ScanInfo scanInfo,
List<? extends KeyValueScanner> scanners,
ScanType scanType,
long smallestReadPoint,
long earliestPutTs,
byte[] dropDeletesFromRow,
byte[] dropDeletesToRow) |
|
StoreScanner(HStore store,
ScanInfo scanInfo,
Scan scan,
NavigableSet<byte[]> columns,
long readPt)
Opens a scanner across memstore, snapshot, and all StoreFiles.
|
private |
StoreScanner(HStore store,
Scan scan,
ScanInfo scanInfo,
int numColumns,
long readPt,
boolean cacheBlocks,
ScanType scanType)
An internal constructor.
|
(package private) |
StoreScanner(ScanInfo scanInfo,
int maxVersions,
ScanType scanType,
List<? extends KeyValueScanner> scanners) |
|
StoreScanner(ScanInfo scanInfo,
ScanType scanType,
List<? extends KeyValueScanner> scanners) |
(package private) |
StoreScanner(Scan scan,
ScanInfo scanInfo,
NavigableSet<byte[]> columns,
List<? extends KeyValueScanner> scanners) |
(package private) |
StoreScanner(Scan scan,
ScanInfo scanInfo,
NavigableSet<byte[]> columns,
List<? extends KeyValueScanner> scanners,
ScanType scanType) |
Modifier and Type | Method and Description |
---|---|
private void |
addCurrentScanners(List<? extends KeyValueScanner> scanners) |
protected boolean |
checkFlushed() |
protected void |
checkScanOrder(Cell prevKV,
Cell kv,
CellComparator comparator)
Check whether scan as expected order nnnn
|
private static void |
clearAndClose(List<KeyValueScanner> scanners) |
void |
close()
Close the KeyValue scanner.
|
private void |
close(boolean withDelayedScannersClose) |
(package private) static void |
enableLazySeekGlobally(boolean enable) |
(package private) List<KeyValueScanner> |
getAllScannersForTesting()
Used in testing.
|
long |
getEstimatedNumberOfKvsScanned()
Returns The estimated number of KVs seen by this scanner (includes some skipped KVs).
|
Cell |
getNextIndexedKey() |
long |
getReadPoint()
Returns the read point of the current scan
|
(package private) boolean |
isScanUsePread() |
private ScannerContext.NextState |
needToReturn(List<Cell> outResult)
If the top cell won't be flushed into disk, the new top cell may be changed after
#reopenAfterFlush.
|
protected KeyValueHeap |
newKVHeap(List<? extends KeyValueScanner> scanners,
CellComparator comparator) |
KeyValue |
next()
Return the next Cell in this scanner, iterating the scanner
|
boolean |
next(List<Cell> outResult,
ScannerContext scannerContext)
Get the next row of values from this Store.
|
private void |
parallelSeek(List<? extends KeyValueScanner> scanners,
Cell kv)
Seek storefiles in parallel to optimize IO latency as much as possible
|
Cell |
peek()
Look at the next Cell in this scanner, but do not iterate scanner.
|
protected boolean |
reopenAfterFlush()
Returns if top of heap has changed (and KeyValueHeap has to try the next KV)
|
boolean |
reseek(Cell kv)
Reseek the scanner at or after the specified KeyValue.
|
protected void |
resetKVHeap(List<? extends KeyValueScanner> scanners,
CellComparator comparator) |
private void |
resetQueryMatcher(Cell lastTopKey) |
boolean |
seek(Cell key)
Seek the scanner at or after the specified KeyValue.
|
private void |
seekAllScanner(ScanInfo scanInfo,
List<? extends KeyValueScanner> scanners) |
protected boolean |
seekAsDirection(Cell kv)
Do a reseek in a normal StoreScanner(scan forward) n * @return true if scanner has values left,
false if end of scanner n
|
private void |
seekOrSkipToNextColumn(Cell cell) |
private void |
seekOrSkipToNextRow(Cell cell) |
protected void |
seekScanners(List<? extends KeyValueScanner> scanners,
Cell seekKey,
boolean isLazy,
boolean isParallelSeek)
Seek the specified scanners with the given key nn * @param isLazy true if using lazy seek
|
protected boolean |
seekToNextRow(Cell c) |
protected List<KeyValueScanner> |
selectScannersFrom(HStore store,
List<? extends KeyValueScanner> allScanners)
Filters the given list of scanners using Bloom filter, time range, and TTL.
|
void |
shipped()
Called after a batch of rows scanned and set to be returned to client.
|
protected boolean |
trySkipToNextColumn(Cell cell)
|
protected boolean |
trySkipToNextRow(Cell cell)
See if we should actually SEEK or rather just SKIP to the next Cell (see HBASE-13109).
|
(package private) void |
trySwitchToStreamRead() |
private void |
updateMetricsStore(boolean memstoreRead) |
void |
updateReaders(List<HStoreFile> sfs,
List<KeyValueScanner> memStoreScanners)
Notify observers.
|
backwardSeek, seekToLastRow, seekToPreviousRow
doRealSeek, enforceSeek, getFilePath, isFileScanner, realSeekDone, requestSeek, shouldUseScanner
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
backwardSeek, enforceSeek, getFilePath, getScannerOrder, isFileScanner, realSeekDone, requestSeek, seekToLastRow, seekToPreviousRow, shouldUseScanner
next
private static final org.slf4j.Logger LOG
private final CellComparator comparator
private ScanQueryMatcher matcher
protected KeyValueHeap heap
private boolean cacheBlocks
private long countPerRow
private int storeLimit
private int storeOffset
private volatile boolean closing
private final boolean get
private final boolean explicitColumnQuery
private final boolean useRowColBloom
private boolean parallelSeekEnabled
private ExecutorService executor
private final long oldestUnexpiredTS
private final long now
private final int minVersions
private final long maxRowSize
private final long cellsPerHeartbeatCheck
long memstoreOnlyReads
long mixedReads
private final List<KeyValueScanner> scannersForDelayedClose
private long kvsScanned
private final long preadMaxBytes
private long bytesRead
static final boolean LAZY_SEEK_ENABLED_BY_DEFAULT
public static final String STORESCANNER_PARALLEL_SEEK_ENABLE
private static boolean lazySeekEnabledGlobally
public static final String HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
public static final long DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
.public static final String STORESCANNER_PREAD_MAX_BYTES
private final Scan.ReadType readType
private boolean scanUsePread
private volatile boolean flushed
private final List<KeyValueScanner> flushedstoreFileScanners
private final List<KeyValueScanner> memStoreScannersAfterFlush
final List<KeyValueScanner> currentScanners
private final ReentrantLock flushLock
private final ReentrantLock closeLock
protected final long readPt
private boolean topChanged
private static final Scan SCAN_FOR_COMPACTION
private StoreScanner(HStore store, Scan scan, ScanInfo scanInfo, int numColumns, long readPt, boolean cacheBlocks, ScanType scanType)
public StoreScanner(HStore store, ScanInfo scanInfo, Scan scan, NavigableSet<byte[]> columns, long readPt) throws IOException
store
- who we scanscan
- the speccolumns
- which columns we are scanning nIOException
public StoreScanner(HStore store, ScanInfo scanInfo, List<? extends KeyValueScanner> scanners, ScanType scanType, long smallestReadPoint, long earliestPutTs) throws IOException
Opens a scanner across specified StoreFiles/MemStoreSegments.
store
- who we scanscanners
- ancillary scannerssmallestReadPoint
- the readPoint that we should use for tracking versionsIOException
public StoreScanner(HStore store, ScanInfo scanInfo, List<? extends KeyValueScanner> scanners, long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow) throws IOException
Opens a scanner across specified StoreFiles.
store
- who we scanscanners
- ancillary scannerssmallestReadPoint
- the readPoint that we should use for tracking versionsdropDeletesFromRow
- The inclusive left bound of the range; can be EMPTY_START_ROW.dropDeletesToRow
- The exclusive right bound of the range; can be EMPTY_END_ROW.IOException
private StoreScanner(HStore store, ScanInfo scanInfo, List<? extends KeyValueScanner> scanners, ScanType scanType, long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow) throws IOException
IOException
public StoreScanner(ScanInfo scanInfo, ScanType scanType, List<? extends KeyValueScanner> scanners) throws IOException
IOException
StoreScanner(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> columns, List<? extends KeyValueScanner> scanners) throws IOException
IOException
StoreScanner(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> columns, List<? extends KeyValueScanner> scanners, ScanType scanType) throws IOException
IOException
StoreScanner(ScanInfo scanInfo, int maxVersions, ScanType scanType, List<? extends KeyValueScanner> scanners) throws IOException
IOException
private void addCurrentScanners(List<? extends KeyValueScanner> scanners)
private void seekAllScanner(ScanInfo scanInfo, List<? extends KeyValueScanner> scanners) throws IOException
IOException
boolean isScanUsePread()
protected void seekScanners(List<? extends KeyValueScanner> scanners, Cell seekKey, boolean isLazy, boolean isParallelSeek) throws IOException
isParallelSeek
- true if using parallel seek nIOException
protected void resetKVHeap(List<? extends KeyValueScanner> scanners, CellComparator comparator) throws IOException
IOException
protected KeyValueHeap newKVHeap(List<? extends KeyValueScanner> scanners, CellComparator comparator) throws IOException
IOException
protected List<KeyValueScanner> selectScannersFrom(HStore store, List<? extends KeyValueScanner> allScanners)
Will be overridden by testcase so declared as protected.
public Cell peek()
KeyValueScanner
peek
in interface KeyValueScanner
public KeyValue next()
KeyValueScanner
next
in interface KeyValueScanner
public void close()
KeyValueScanner
close
in interface Closeable
close
in interface AutoCloseable
close
in interface InternalScanner
close
in interface KeyValueScanner
private void close(boolean withDelayedScannersClose)
public boolean seek(Cell key) throws IOException
KeyValueScanner
seek
in interface KeyValueScanner
key
- seek valueIOException
public boolean next(List<Cell> outResult, ScannerContext scannerContext) throws IOException
next
in interface InternalScanner
outResult
- return output array n * @return true if more rows exist after this one, false if
scanner is doneIOException
- eprivate void updateMetricsStore(boolean memstoreRead)
private ScannerContext.NextState needToReturn(List<Cell> outResult)
outResult
- the cells which are visible for user scanprivate void seekOrSkipToNextRow(Cell cell) throws IOException
IOException
private void seekOrSkipToNextColumn(Cell cell) throws IOException
IOException
protected boolean trySkipToNextRow(Cell cell) throws IOException
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. Example:
| BLOCK 1 | BLOCK 2 | | r1/c1, r1/c2, r1/c3 | r1/c4, r1/c5, r2/c1 | ^ ^ | | Next Index Key SEEK_NEXT_ROW (before r2/c1) | BLOCK 1 | BLOCK 2 | | r1/c1/t5, r1/c1/t4, r1/c1/t3 | r1/c1/t2, r1/c1/T1, r1/c2/T3 | ^ ^ | | Next Index Key SEEK_NEXT_COLNow 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.
cell
- current cellIOException
protected boolean trySkipToNextColumn(Cell cell) throws IOException
cell
- current cellIOException
public long getReadPoint()
ChangedReadersObserver
getReadPoint
in interface ChangedReadersObserver
private static void clearAndClose(List<KeyValueScanner> scanners)
public void updateReaders(List<HStoreFile> sfs, List<KeyValueScanner> memStoreScanners) throws IOException
ChangedReadersObserver
updateReaders
in interface ChangedReadersObserver
sfs
- The new filesmemStoreScanners
- scanner of current memstoreIOException
- eprotected final boolean reopenAfterFlush() throws IOException
IOException
private void resetQueryMatcher(Cell lastTopKey)
protected void checkScanOrder(Cell prevKV, Cell kv, CellComparator comparator) throws IOException
IOException
protected boolean seekToNextRow(Cell c) throws IOException
IOException
protected boolean seekAsDirection(Cell kv) throws IOException
IOException
public boolean reseek(Cell kv) throws IOException
KeyValueScanner
reseek
in interface KeyValueScanner
kv
- seek value (should be non-null)IOException
void trySwitchToStreamRead()
protected final boolean checkFlushed()
private void parallelSeek(List<? extends KeyValueScanner> scanners, Cell kv) throws IOException
scanners
- the list KeyValueScanner
s to be read fromkv
- the KeyValue on which the operation is being requested nIOException
List<KeyValueScanner> getAllScannersForTesting()
static void enableLazySeekGlobally(boolean enable)
public long getEstimatedNumberOfKvsScanned()
public Cell getNextIndexedKey()
getNextIndexedKey
in interface KeyValueScanner
getNextIndexedKey
in class NonLazyKeyValueScanner
public void shipped() throws IOException
Shipper
shipped
in interface Shipper
shipped
in class NonLazyKeyValueScanner
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.