@InterfaceAudience.Public public interface AdvancedScanResultConsumer extends ScanResultConsumerBase
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.
Modifier and Type | Interface and Description |
---|---|
static interface |
AdvancedScanResultConsumer.ScanController
Used to suspend or stop a scan, or get a scan cursor if available.
|
static interface |
AdvancedScanResultConsumer.ScanResumer
Used to resume a scan.
|
Modifier and Type | Method and Description |
---|---|
default void |
onHeartbeat(AdvancedScanResultConsumer.ScanController controller)
Indicate that there is a heartbeat message but we have not cumulated enough cells to call
onNext(Result[], ScanController) . |
void |
onNext(Result[] results,
AdvancedScanResultConsumer.ScanController controller)
Indicate that we have receive some data.
|
onComplete, onError, onScanMetricsCreated
void onNext(Result[] results, AdvancedScanResultConsumer.ScanController controller)
results
- the data fetched from HBase service.controller
- used to suspend or terminate the scan. Notice that the controller
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.default void onHeartbeat(AdvancedScanResultConsumer.ScanController controller)
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 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.
controller
- used to suspend or terminate the scan. Notice that the controller
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.Copyright © 2007–2019 Cloudera. All rights reserved.