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
Modifier and TypeFieldDescriptionprotected final CellComparator
private final ScannerContext
private final FilterWrapper
private boolean
protected final boolean
protected Cell
If 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) KeyValueHeap
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.private static final org.slf4j.Logger
private final long
A mocked list implementation - discards all updates.private final String
private final long
protected final HRegion
private RegionServerServices
private final ConcurrentHashMap<RegionScanner,
Long> protected final byte[]
(package private) KeyValueHeap
-
Constructor Summary
ConstructorDescriptionRegionScannerImpl
(Scan scan, List<KeyValueScanner> additionalScanners, HRegion region, long nonceGroup, long nonce) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkClientDisconnect
(Optional<RpcCall> rpcCall) void
close()
Closes the scanner and releases any resources it has allocatedprivate void
private boolean
This function is to maintain backward compatibility for 0.94 filters.private boolean
filterRowKey
(Cell current) int
getBatch()
long
long
Returns The Scanner's MVCC readPt seeMultiVersionConcurrencyControl
Returns The RegionInfo for this scanner.private IOException
handleException
(List<KeyValueScanner> instantiatedScanners, Throwable t) private static boolean
private void
incrementCountOfRowsFilteredMetric
(ScannerContext scannerContext) private void
incrementCountOfRowsScannedMetric
(ScannerContext scannerContext) protected void
initializeKVHeap
(List<KeyValueScanner> scanners, List<KeyValueScanner> joinedScanners, HRegion region) private void
initializeScanners
(Scan scan, List<KeyValueScanner> additionalScanners) boolean
Returns True if a filter rules the scanner is over, done.private boolean
private boolean
joinedHeapMayHaveData
(Cell currentRowCell) Returns true when the joined heap may have data for the current rowprivate boolean
moreCellsInRow
(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.boolean
Grab the next row's worth of values.boolean
next
(List<Cell> outResults, ScannerContext scannerContext) Grab the next row's worth of values.private boolean
nextInternal
(List<Cell> results, ScannerContext scannerContext) boolean
Grab the next row's worth of values.boolean
nextRaw
(List<Cell> outResults, ScannerContext scannerContext) Grab the next row's worth of values.protected boolean
nextRow
(ScannerContext scannerContext, Cell curRowCell) private boolean
populateFromJoinedHeap
(List<Cell> results, ScannerContext scannerContext) Returns true if more cells exist after this batch, false if scanner is doneprivate boolean
populateResult
(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 reacedboolean
reseek
(byte[] row) Do a reseek to the required row.protected final void
Reset both the filter and the old filter.private void
resetProgress
(ScannerContext scannerContext, int initialBatchProgress, long initialSizeProgress, long initialHeapSizeProgress) void
run()
Called at the end of an Rpc CallRpcCallContext
void
shipped()
Called after a batch of rows scanned and set to be returned to client.protected boolean
shouldStop
(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:RegionScanner
Returns The RegionInfo for this scanner.- Specified by:
getRegionInfo
in 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:
getMaxResultSize
in interfaceRegionScanner
- Returns:
- The preferred max buffersize. See
Scan.setMaxResultSize(long)
-
getMvccReadPoint
Description copied from interface:RegionScanner
Returns The Scanner's MVCC readPt seeMultiVersionConcurrencyControl
- Specified by:
getMvccReadPoint
in interfaceRegionScanner
-
getBatch
- Specified by:
getBatch
in interfaceRegionScanner
- Returns:
- The limit on the number of cells to retrieve on each call to next(). See
Scan.setBatch(int)
-
getOperationId
- Specified by:
getOperationId
in interfaceRegionScanner
- Returns:
- The Scanner's
OperationWithAttributes.ID_ATRIBUTE
value, 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:InternalScanner
Grab the next row's worth of values.- Specified by:
next
in 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:InternalScanner
Grab the next row's worth of values.- Specified by:
next
in 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:RegionScanner
Grab 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:
nextRaw
in 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:RegionScanner
Grab the next row's worth of values. TheScannerContext
is used to enforce and track any limits associated with this call. Any progress that exists in theScannerContext
prior to calling this method will be LOST ifScannerContext.getKeepProgress()
is false. Upon returning from this method, theScannerContext
will 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:
nextRaw
in interfaceRegionScanner
- Parameters:
outResults
- return output arrayscannerContext
- TheScannerContext
instance 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:
isFilterDone
in 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:InternalScanner
Closes the scanner and releases any resources it has allocated- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceInternalScanner
-
reseek
Description copied from interface:RegionScanner
Do 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:
reseek
in interfaceRegionScanner
- Throws:
IOException
-
shipped
Description copied from interface:Shipper
Called after a batch of rows scanned and set to be returned to client. Any in between cleanup can be done here.- Specified by:
shipped
in interfaceShipper
- Throws:
IOException
-
run
Description copied from interface:RpcCallback
Called at the end of an Rpc CallRpcCallContext
- Specified by:
run
in interfaceRpcCallback
- Throws:
IOException
-