@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 |
---|---|
static long |
DEFAULT_HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK
Default value of
HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK . |
static 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 String |
STORESCANNER_PARALLEL_SEEK_ENABLE |
static 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,
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.
|
StoreScanner(HStore store,
ScanInfo scanInfo,
Scan scan,
NavigableSet<byte[]> columns,
long readPt)
Opens a scanner across memstore, snapshot, and all StoreFiles.
|
StoreScanner(ScanInfo scanInfo,
ScanType scanType,
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() |
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.
|
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(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(List<? extends KeyValueScanner> scanners,
Cell seekKey,
boolean isLazy,
boolean isParallelSeek)
Seek the specified scanners with the given key
|
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).
|
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
protected final HStore store
protected KeyValueHeap heap
public static final String STORESCANNER_PARALLEL_SEEK_ENABLE
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
protected final long readPt
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 scanningIOException
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
public StoreScanner(ScanInfo scanInfo, ScanType scanType, List<? extends KeyValueScanner> scanners) throws IOException
IOException
protected void seekScanners(List<? extends KeyValueScanner> scanners, Cell seekKey, boolean isLazy, boolean isParallelSeek) throws IOException
scanners
- seekKey
- isLazy
- true if using lazy seekisParallelSeek
- true if using parallel seekIOException
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
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
- scannerContext
- IOException
- eprotected 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()
getReadPoint
in interface ChangedReadersObserver
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
protected void checkScanOrder(Cell prevKV, Cell kv, CellComparator comparator) throws IOException
prevKV
- kv
- comparator
- IOException
protected boolean seekToNextRow(Cell c) throws IOException
IOException
protected boolean seekAsDirection(Cell kv) throws IOException
kv
- IOException
public boolean reseek(Cell kv) throws IOException
KeyValueScanner
reseek
in interface KeyValueScanner
kv
- seek value (should be non-null)IOException
protected final boolean checkFlushed()
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–2019 Cloudera. All rights reserved.