Package org.apache.hadoop.hbase.client
Class AsyncTableResultScanner
java.lang.Object
org.apache.hadoop.hbase.client.AsyncTableResultScanner
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<Result>,AdvancedScanResultConsumer,ResultScanner,ScanResultConsumerBase
@Private
class AsyncTableResultScanner
extends Object
implements ResultScanner, AdvancedScanResultConsumer
The
ResultScanner implementation for RawAsyncTableImpl. It will fetch data
automatically in background and cache it in memory. Typically, the maxCacheSize will be
2 * scan.getMaxResultSize().-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.client.AdvancedScanResultConsumer
AdvancedScanResultConsumer.ScanController, AdvancedScanResultConsumer.ScanResumer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate booleanprivate Throwableprivate static final org.slf4j.Loggerprivate final longprivate final Scanprivate ScanMetricsprivate io.opentelemetry.api.trace.Spanprivate final TableName -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddToCache(Result result) voidclose()Closes the scanner and releases any resources it has allocatedReturns the scan metrics, ornullif we do not enable metrics.(package private) io.opentelemetry.api.trace.SpangetSpan()(package private) booleannext()Grab the next row's worth of values.voidIndicate that the scan operation is completed normally.voidIndicate that we hit an unrecoverable error and the scan operation is terminated.voidonHeartbeat(AdvancedScanResultConsumer.ScanController controller) Indicate that there is a heartbeat message but we have not cumulated enough cells to callAdvancedScanResultConsumer.onNext(Result[], ScanController).voidonNext(Result[] results, AdvancedScanResultConsumer.ScanController controller) Indicate that we have receive some data.voidonScanMetricsCreated(ScanMetrics scanMetrics) Ifscan.isScanMetricsEnabled()returns true, then this method will be called prior to all other methods in this interface to give you theScanMetricsinstance for this scan operation.booleanAllow the client to renew the scanner's lease on the server.private void(package private) voidsetSpan(io.opentelemetry.api.trace.Span span) private voidprivate voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.apache.hadoop.hbase.client.ResultScanner
iterator, next
-
Field Details
-
LOG
-
tableName
-
maxCacheSize
-
scan
-
queue
-
scanMetrics
-
cacheSize
-
closed
-
error
-
resumer
-
span
-
-
Constructor Details
-
AsyncTableResultScanner
-
-
Method Details
-
addToCache
-
stopPrefetch
-
getSpan
io.opentelemetry.api.trace.Span getSpan() -
setSpan
-
onNext
Description copied from interface:AdvancedScanResultConsumerIndicate that we have receive some data.- Specified by:
onNextin interfaceAdvancedScanResultConsumer- Parameters:
results- the data fetched from HBase service.controller- used to suspend or terminate the scan. Notice that thecontrollerinstance is only valid within scope of onNext method. You can only call its method in onNext, do NOT store it and call it later outside onNext.
-
onHeartbeat
Description copied from interface:AdvancedScanResultConsumerIndicate that there is a heartbeat message but we have not cumulated enough cells to callAdvancedScanResultConsumer.onNext(Result[], ScanController).Note that this method will always be called when RS returns something to us but we do not have enough cells to call
AdvancedScanResultConsumer.onNext(Result[], ScanController). Sometimes it may not be a 'heartbeat' message for RS, for example, we have a large row with many cells and size limit is exceeded before sending all the cells for this row. For RS it does send some data to us and the time limit has not been reached, but we can not return the data to client so here we call this method to tell client we have already received something.This method give you a chance to terminate a slow scan operation.
- Specified by:
onHeartbeatin interfaceAdvancedScanResultConsumer- Parameters:
controller- used to suspend or terminate the scan. Notice that thecontrollerinstance is only valid within the scope of onHeartbeat method. You can only call its method in onHeartbeat, do NOT store it and call it later outside onHeartbeat.
-
onError
Description copied from interface:ScanResultConsumerBaseIndicate that we hit an unrecoverable error and the scan operation is terminated.We will not call
ScanResultConsumerBase.onComplete()after callingScanResultConsumerBase.onError(Throwable).- Specified by:
onErrorin interfaceScanResultConsumerBase
-
onComplete
Description copied from interface:ScanResultConsumerBaseIndicate that the scan operation is completed normally.- Specified by:
onCompletein interfaceScanResultConsumerBase
-
onScanMetricsCreated
Description copied from interface:ScanResultConsumerBaseIfscan.isScanMetricsEnabled()returns true, then this method will be called prior to all other methods in this interface to give you theScanMetricsinstance for this scan operation. TheScanMetricsinstance will be updated on-the-fly during the scan, you can store it somewhere to get the metrics at any time if you want.- Specified by:
onScanMetricsCreatedin interfaceScanResultConsumerBase
-
resumePrefetch
-
terminateResumerIfPossible
-
next
Description copied from interface:ResultScannerGrab the next row's worth of values. The scanner will return a Result.- Specified by:
nextin interfaceResultScanner- Returns:
- Result object if there is another row, null if the scanner is exhausted.
- Throws:
IOException- e
-
close
Description copied from interface:ResultScannerCloses the scanner and releases any resources it has allocated- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceResultScanner
-
renewLease
Description copied from interface:ResultScannerAllow the client to renew the scanner's lease on the server.- Specified by:
renewLeasein interfaceResultScanner- Returns:
- true if the lease was successfully renewed, false otherwise.
-
isSuspended
boolean isSuspended() -
getScanMetrics
Description copied from interface:ResultScannerReturns the scan metrics, ornullif we do not enable metrics.- Specified by:
getScanMetricsin interfaceResultScanner
-