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 |
|---|---|
static long |
DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
Default value of
HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK. |
static java.lang.String |
HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
The number of cells scanned in between timeout checks.
|
protected KeyValueHeap |
heap |
protected long |
readPt |
protected HStore |
store |
static java.lang.String |
STORESCANNER_PARALLEL_SEEK_ENABLE |
static java.lang.String |
STORESCANNER_PREAD_MAX_BYTES
If the read type if Scan.ReadType.DEFAULT, we will start with pread, and if the kvs we scanned
reaches this limit, we will reopen the scanner with stream.
|
NO_NEXT_INDEXED_KEY| Constructor and Description |
|---|
StoreScanner(HStore store,
ScanInfo scanInfo,
java.util.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,
java.util.List<? extends KeyValueScanner> scanners,
ScanType scanType,
long smallestReadPoint,
long earliestPutTs)
Used for store file compaction and memstore compaction.
|
StoreScanner(HStore store,
ScanInfo scanInfo,
Scan scan,
java.util.NavigableSet<byte[]> columns,
long readPt)
Opens a scanner across memstore, snapshot, and all StoreFiles.
|
StoreScanner(ScanInfo scanInfo,
ScanType scanType,
java.util.List<? extends KeyValueScanner> scanners) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkFlushed() |
protected void |
checkScanOrder(Cell prevKV,
Cell kv,
CellComparator comparator)
Check whether scan as expected order
|
void |
close()
Close the KeyValue scanner.
|
long |
getEstimatedNumberOfKvsScanned() |
Cell |
getNextIndexedKey() |
long |
getReadPoint() |
long |
getScannerOrder()
Get the order of this KeyValueScanner.
|
KeyValue |
next()
Return the next Cell in this scanner, iterating the scanner
|
boolean |
next(java.util.List<Cell> outResult,
ScannerContext scannerContext)
Get the next row of values from this Store.
|
Cell |
peek()
Look at the next Cell in this scanner, but do not iterate scanner.
|
protected boolean |
reopenAfterFlush() |
boolean |
reseek(Cell kv)
Reseek the scanner at or after the specified KeyValue.
|
protected void |
resetKVHeap(java.util.List<? extends KeyValueScanner> scanners,
CellComparator comparator) |
boolean |
seek(Cell key)
Seek the scanner at or after the specified KeyValue.
|
protected boolean |
seekAsDirection(Cell kv)
Do a reseek in a normal StoreScanner(scan forward)
|
protected void |
seekScanners(java.util.List<? extends KeyValueScanner> scanners,
Cell seekKey,
boolean isLazy,
boolean isParallelSeek)
Seek the specified scanners with the given key
|
protected boolean |
seekToNextRow(Cell c) |
protected java.util.List<KeyValueScanner> |
selectScannersFrom(HStore store,
java.util.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).
|
void |
updateReaders(java.util.List<HStoreFile> sfs,
java.util.List<KeyValueScanner> memStoreScanners)
Notify observers.
|
backwardSeek, seekToLastRow, seekToPreviousRowclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbackwardSeek, enforceSeek, getFilePath, isFileScanner, realSeekDone, requestSeek, seekToLastRow, seekToPreviousRow, shouldUseScannernextprotected final HStore store
protected KeyValueHeap heap
public static final java.lang.String STORESCANNER_PARALLEL_SEEK_ENABLE
public static final java.lang.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 java.lang.String STORESCANNER_PREAD_MAX_BYTES
protected final long readPt
public StoreScanner(HStore store, ScanInfo scanInfo, Scan scan, java.util.NavigableSet<byte[]> columns, long readPt) throws java.io.IOException
store - who we scanscan - the speccolumns - which columns we are scanningjava.io.IOExceptionpublic StoreScanner(HStore store, ScanInfo scanInfo, java.util.List<? extends KeyValueScanner> scanners, ScanType scanType, long smallestReadPoint, long earliestPutTs) throws java.io.IOException
Opens a scanner across specified StoreFiles/MemStoreSegments.
store - who we scanscanners - ancillary scannerssmallestReadPoint - the readPoint that we should use for tracking versionsjava.io.IOExceptionpublic StoreScanner(HStore store, ScanInfo scanInfo, java.util.List<? extends KeyValueScanner> scanners, long smallestReadPoint, long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow) throws java.io.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.java.io.IOExceptionpublic StoreScanner(ScanInfo scanInfo,
ScanType scanType,
java.util.List<? extends KeyValueScanner> scanners)
throws java.io.IOException
java.io.IOExceptionprotected void seekScanners(java.util.List<? extends KeyValueScanner> scanners, Cell seekKey, boolean isLazy, boolean isParallelSeek) throws java.io.IOException
scanners - seekKey - isLazy - true if using lazy seekisParallelSeek - true if using parallel seekjava.io.IOExceptionprotected void resetKVHeap(java.util.List<? extends KeyValueScanner> scanners, CellComparator comparator) throws java.io.IOException
java.io.IOExceptionprotected java.util.List<KeyValueScanner> selectScannersFrom(HStore store, java.util.List<? extends KeyValueScanner> allScanners)
Will be overridden by testcase so declared as protected.
public Cell peek()
KeyValueScannerpeek in interface KeyValueScannerpublic KeyValue next()
KeyValueScannernext in interface KeyValueScannerpublic void close()
KeyValueScannerclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface InternalScannerclose in interface KeyValueScannerpublic boolean seek(Cell key)
throws java.io.IOException
KeyValueScannerseek in interface KeyValueScannerkey - seek valuejava.io.IOExceptionpublic boolean next(java.util.List<Cell> outResult,
ScannerContext scannerContext)
throws java.io.IOException
next in interface InternalScanneroutResult - scannerContext - java.io.IOException - eprotected boolean trySkipToNextRow(Cell cell)
throws java.io.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_COL
Now 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 celljava.io.IOExceptionprotected boolean trySkipToNextColumn(Cell cell)
throws java.io.IOException
cell - current celljava.io.IOExceptionpublic long getReadPoint()
getReadPoint in interface ChangedReadersObserverpublic void updateReaders(java.util.List<HStoreFile> sfs,
java.util.List<KeyValueScanner> memStoreScanners)
throws java.io.IOException
ChangedReadersObserverupdateReaders in interface ChangedReadersObserversfs - The new filesmemStoreScanners - scanner of current memstorejava.io.IOException - eprotected final boolean reopenAfterFlush()
throws java.io.IOException
java.io.IOExceptionprotected void checkScanOrder(Cell prevKV,
Cell kv,
CellComparator comparator)
throws java.io.IOException
prevKV - kv - comparator - java.io.IOExceptionprotected boolean seekToNextRow(Cell c)
throws java.io.IOException
java.io.IOExceptionprotected boolean seekAsDirection(Cell kv)
throws java.io.IOException
kv - java.io.IOExceptionpublic boolean reseek(Cell kv)
throws java.io.IOException
KeyValueScannerreseek in interface KeyValueScannerkv - seek value (should be non-null)java.io.IOExceptionprotected final boolean checkFlushed()
public long getScannerOrder()
KeyValueScannergetScannerOrder in interface KeyValueScannerKeyValueScanner.getScannerOrder()public long getEstimatedNumberOfKvsScanned()
public Cell getNextIndexedKey()
getNextIndexedKey in interface KeyValueScanner