Interface AdvancedScanResultConsumer
- All Superinterfaces:
ScanResultConsumerBase
- All Known Implementing Classes:
AsyncTableResultScanner
,ClientMetaTableAccessor.MetaTableScanResultConsumer
All results that match the given scan object will be passed to this class by calling
onNext(Result[], ScanController)
. ScanResultConsumerBase.onComplete()
means the scan is finished, and
ScanResultConsumerBase.onError(Throwable)
means we hit an unrecoverable error and the scan is terminated.
onHeartbeat(ScanController)
means the RS is still working but we can not get a valid
result to call onNext(Result[], ScanController)
. This is usually because the matched
results are too sparse, for example, a filter which almost filters out everything is specified.
Notice that, all the methods here will be called directly in the thread which we send request to
HBase service. So if you want the asynchronous scanner fetch data from HBase in background while
you process the returned data, you need to move the processing work to another thread to make the
onNext(Result[], ScanController)
call return immediately. And please do NOT do any time
consuming tasks in these methods unless you know what you are doing.
- Since:
- 2.0.0
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Used to suspend or stop a scan, or get a scan cursor if available.static interface
Used to resume a scan. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
onHeartbeat
(AdvancedScanResultConsumer.ScanController controller) Indicate that there is a heartbeat message but we have not cumulated enough cells to callonNext(Result[], ScanController)
.void
onNext
(Result[] results, AdvancedScanResultConsumer.ScanController controller) Indicate that we have receive some data.Methods inherited from interface org.apache.hadoop.hbase.client.ScanResultConsumerBase
onComplete, onError, onScanMetricsCreated
-
Method Details
-
onNext
Indicate that we have receive some data.- Parameters:
results
- the data fetched from HBase service.controller
- used to suspend or terminate the scan. Notice that thecontroller
instance 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
Indicate that there is a heartbeat message but we have not cumulated enough cells to callonNext(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
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.
- Parameters:
controller
- used to suspend or terminate the scan. Notice that thecontroller
instance 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.
-