Class RegionScannerImpl
java.lang.Object
org.apache.hadoop.hbase.regionserver.RegionScannerImpl
- All Implemented Interfaces:
Closeable,AutoCloseable,RpcCallback,InternalScanner,RegionScanner,Shipper
- Direct Known Subclasses:
ReversedRegionScannerImpl
RegionScannerImpl is used to combine scanners from multiple Stores (aka column families).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CellComparatorprivate final ScannerContextprivate final FilterWrapperprivate booleanprotected final booleanprotected CellIf the joined heap data gathering is interrupted due to scan limits, this will contain the row for which we are populating the values.(package private) KeyValueHeapHeap of key-values that are not essential for the provided filters and are thus read on demand, if on-demand column family loading is enabled.private static final org.slf4j.Loggerprivate final longA mocked list implementation - discards all updates.private final Stringprivate final longprotected final HRegionprivate RegionServerServicesprivate final ConcurrentHashMap<RegionScanner,Long> protected final byte[](package private) KeyValueHeap -
Constructor Summary
ConstructorsConstructorDescriptionRegionScannerImpl(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region, long nonceGroup, long nonce) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckClientDisconnect(Optional<RpcCall> rpcCall) voidclose()Closes the scanner and releases any resources it has allocatedprivate voidprivate booleanThis function is to maintain backward compatibility for 0.94 filters.private booleanfilterRowKey(Cell current) intgetBatch()longlongReturns The Scanner's MVCC readPt seeMultiVersionConcurrencyControlReturns The RegionInfo for this scanner.private IOExceptionhandleException(List<KeyValueScanner> instantiatedScanners, Throwable t) private static booleanprivate voidincrementCountOfRowsFilteredMetric(ScannerContext scannerContext) private voidincrementCountOfRowsScannedMetric(ScannerContext scannerContext) protected voidinitializeKVHeap(List<KeyValueScanner> scanners, List<KeyValueScanner> joinedScanners, HRegion region) private voidinitializeScanners(Scan scan, List<KeyValueScanner> additionalScanners) booleanReturns True if a filter rules the scanner is over, done.private booleanprivate booleanjoinedHeapMayHaveData(Cell currentRowCell) Returns true when the joined heap may have data for the current rowprivate booleanmoreCellsInRow(Cell nextKv, Cell currentRowCell) Based on the nextKv in the heap, and the current row, decide whether or not there are more cells to be read in the heap.booleanGrab the next row's worth of values.booleannext(List<Cell> outResults, ScannerContext scannerContext) Grab the next row's worth of values.private booleannextInternal(List<Cell> results, ScannerContext scannerContext) booleanGrab the next row's worth of values.booleannextRaw(List<Cell> outResults, ScannerContext scannerContext) Grab the next row's worth of values.protected booleannextRow(ScannerContext scannerContext, Cell curRowCell) private booleanpopulateFromJoinedHeap(List<Cell> results, ScannerContext scannerContext) Returns true if more cells exist after this batch, false if scanner is doneprivate booleanpopulateResult(List<Cell> results, KeyValueHeap heap, ScannerContext scannerContext, Cell currentRowCell) Fetches records with currentRow into results list, until next row, batchLimit (if not -1) is reached, or remainingResultSize (if not -1) is reacedbooleanreseek(byte[] row) Do a reseek to the required row.protected final voidReset both the filter and the old filter.private voidresetProgress(ScannerContext scannerContext, int initialBatchProgress, long initialSizeProgress, long initialHeapSizeProgress) voidrun()Called at the end of an Rpc CallRpcCallContextvoidshipped()Called after a batch of rows scanned and set to be returned to client.protected booleanshouldStop(Cell currentRowCell)
-
Field Details
-
LOG
-
storeHeap
-
joinedHeap
Heap of key-values that are not essential for the provided filters and are thus read on demand, if on-demand column family loading is enabled. -
joinedContinuationRow
If the joined heap data gathering is interrupted due to scan limits, this will contain the row for which we are populating the values. -
filterClosed
-
stopRow
-
includeStopRow
-
region
-
comparator
-
scannerReadPoints
-
readPt
-
maxResultSize
-
defaultScannerContext
-
filter
-
operationId
-
rsServices
-
MOCKED_LIST
A mocked list implementation - discards all updates.
-
-
Constructor Details
-
RegionScannerImpl
RegionScannerImpl(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region, long nonceGroup, long nonce) throws IOException - Throws:
IOException
-
-
Method Details
-
getRegionInfo
Description copied from interface:RegionScannerReturns The RegionInfo for this scanner.- Specified by:
getRegionInfoin interfaceRegionScanner
-
hasNonce
-
initializeScanners
private void initializeScanners(Scan scan, List<KeyValueScanner> additionalScanners) throws IOException - Throws:
IOException
-
initializeKVHeap
protected void initializeKVHeap(List<KeyValueScanner> scanners, List<KeyValueScanner> joinedScanners, HRegion region) throws IOException - Throws:
IOException
-
handleException
-
getMaxResultSize
- Specified by:
getMaxResultSizein interfaceRegionScanner- Returns:
- The preferred max buffersize. See
Scan.setMaxResultSize(long)
-
getMvccReadPoint
Description copied from interface:RegionScannerReturns The Scanner's MVCC readPt seeMultiVersionConcurrencyControl- Specified by:
getMvccReadPointin interfaceRegionScanner
-
getBatch
- Specified by:
getBatchin interfaceRegionScanner- Returns:
- The limit on the number of cells to retrieve on each call to next(). See
Scan.setBatch(int)
-
getOperationId
- Specified by:
getOperationIdin interfaceRegionScanner- Returns:
- The Scanner's
OperationWithAttributes.ID_ATRIBUTEvalue, or null if not set.
-
resetFilters
Reset both the filter and the old filter.- Throws:
IOException- in case a filter raises an I/O exception.
-
next
Description copied from interface:InternalScannerGrab the next row's worth of values.- Specified by:
nextin interfaceInternalScanner- Parameters:
outResults- return output array- Returns:
- true if more rows exist after this one, false if scanner is done
- Throws:
IOException- e
-
next
Description copied from interface:InternalScannerGrab the next row's worth of values.- Specified by:
nextin interfaceInternalScanner- Parameters:
outResults- return output array- Returns:
- true if more rows exist after this one, false if scanner is done
- Throws:
IOException- e
-
nextRaw
Description copied from interface:RegionScannerGrab the next row's worth of values. This is a special internal method to be called from coprocessor hooks to avoid expensive setup. Caller must set the thread's readpoint, start and close a region operation, an synchronize on the scanner object. Caller should maintain and update metrics. SeeRegionScanner.nextRaw(List, ScannerContext)- Specified by:
nextRawin interfaceRegionScanner- Parameters:
outResults- return output array- Returns:
- true if more rows exist after this one, false if scanner is done
- Throws:
IOException- e
-
nextRaw
Description copied from interface:RegionScannerGrab the next row's worth of values. TheScannerContextis used to enforce and track any limits associated with this call. Any progress that exists in theScannerContextprior to calling this method will be LOST ifScannerContext.getKeepProgress()is false. Upon returning from this method, theScannerContextwill contain information about the progress made towards the limits. This is a special internal method to be called from coprocessor hooks to avoid expensive setup. Caller must set the thread's readpoint, start and close a region operation, an synchronize on the scanner object. Example:HRegion region = ...; RegionScanner scanner = ... MultiVersionConcurrencyControl.setThreadReadPoint(scanner.getMvccReadPoint()); region.startRegionOperation(); try { synchronized(scanner) { ... boolean moreRows = scanner.nextRaw(values); ... } } finally { region.closeRegionOperation(); }- Specified by:
nextRawin interfaceRegionScanner- Parameters:
outResults- return output arrayscannerContext- TheScannerContextinstance encapsulating all limits that should be tracked during calls to this method. The progress towards these limits can be tracked within this instance.- Returns:
- true if more rows exist after this one, false if scanner is done
- Throws:
IOException- e
-
populateFromJoinedHeap
private boolean populateFromJoinedHeap(List<Cell> results, ScannerContext scannerContext) throws IOException Returns true if more cells exist after this batch, false if scanner is done- Throws:
IOException
-
populateResult
private boolean populateResult(List<Cell> results, KeyValueHeap heap, ScannerContext scannerContext, Cell currentRowCell) throws IOException Fetches records with currentRow into results list, until next row, batchLimit (if not -1) is reached, or remainingResultSize (if not -1) is reaced- Parameters:
heap- KeyValueHeap to fetch data from.It must be positioned on correct row before call.- Returns:
- state of last call to
KeyValueHeap.next() - Throws:
IOException
-
moreCellsInRow
Based on the nextKv in the heap, and the current row, decide whether or not there are more cells to be read in the heap. If the row of the nextKv in the heap matches the current row then there are more cells to be read in the row.- Returns:
- true When there are more cells in the row to be read
-
isFilterDone
Returns True if a filter rules the scanner is over, done.- Specified by:
isFilterDonein interfaceRegionScanner- Returns:
- True if a filter indicates that this scanner will return no further rows.
- Throws:
IOException- in case of I/O failure on a filter.
-
isFilterDoneInternal
- Throws:
IOException
-
checkClientDisconnect
- Throws:
CallerDisconnectedException
-
resetProgress
private void resetProgress(ScannerContext scannerContext, int initialBatchProgress, long initialSizeProgress, long initialHeapSizeProgress) -
nextInternal
- Throws:
IOException
-
incrementCountOfRowsFilteredMetric
-
incrementCountOfRowsScannedMetric
-
joinedHeapMayHaveData
Returns true when the joined heap may have data for the current row- Throws:
IOException
-
filterRow
This function is to maintain backward compatibility for 0.94 filters. HBASE-6429 combines both filterRow & filterRow(List<KeyValue> kvs) functions. While 0.94 code or older, it may not implement hasFilterRow as HBase-6429 expects because 0.94 hasFilterRow() only returns true when filterRow(List<KeyValue> kvs) is overridden not the filterRow(). Therefore, the filterRow() will be skipped.- Throws:
IOException
-
filterRowKey
- Throws:
IOException
-
nextRow
- Throws:
IOException
-
shouldStop
-
closeInternal
-
close
Description copied from interface:InternalScannerCloses the scanner and releases any resources it has allocated- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceInternalScanner
-
reseek
Description copied from interface:RegionScannerDo a reseek to the required row. Should not be used to seek to a key which may come before the current position. Always seeks to the beginning of a row boundary. if row is null- Specified by:
reseekin interfaceRegionScanner- Throws:
IOException
-
shipped
Description copied from interface:ShipperCalled after a batch of rows scanned and set to be returned to client. Any in between cleanup can be done here.- Specified by:
shippedin interfaceShipper- Throws:
IOException
-
run
Description copied from interface:RpcCallbackCalled at the end of an Rpc CallRpcCallContext- Specified by:
runin interfaceRpcCallback- Throws:
IOException
-