@InterfaceAudience.Private class AsyncTableResultScanner extends Object implements ResultScanner, AdvancedScanResultConsumer
ResultScanner implementation for AsyncTable. It will fetch data automatically
in background and cache it in memory. Typically the maxCacheSize will be
2 * scan.getMaxResultSize().AdvancedScanResultConsumer.ScanController, AdvancedScanResultConsumer.ScanResumer| Modifier and Type | Field and Description |
|---|---|
private long |
cacheSize |
private boolean |
closed |
private Throwable |
error |
private static org.slf4j.Logger |
LOG |
private long |
maxCacheSize |
private Queue<Result> |
queue |
private AsyncTable<AdvancedScanResultConsumer> |
rawTable |
private AdvancedScanResultConsumer.ScanResumer |
resumer |
private Scan |
scan |
private ScanMetrics |
scanMetrics |
| Constructor and Description |
|---|
AsyncTableResultScanner(AsyncTable<AdvancedScanResultConsumer> table,
Scan scan,
long maxCacheSize) |
| Modifier and Type | Method and Description |
|---|---|
private void |
addToCache(Result result) |
void |
close()
Closes the scanner and releases any resources it has allocated
|
ScanMetrics |
getScanMetrics() |
(package private) boolean |
isSuspended() |
Result |
next()
Grab the next row's worth of values.
|
void |
onComplete()
Indicate that the scan operation is completed normally.
|
void |
onError(Throwable error)
Indicate that we hit an unrecoverable error and the scan operation is terminated.
|
void |
onHeartbeat(AdvancedScanResultConsumer.ScanController controller)
Indicate that there is a heartbeat message but we have not cumulated enough cells to call
AdvancedScanResultConsumer.onNext(Result[], ScanController). |
void |
onNext(Result[] results,
AdvancedScanResultConsumer.ScanController controller)
Indicate that we have receive some data.
|
void |
onScanMetricsCreated(ScanMetrics scanMetrics)
If
scan.isScanMetricsEnabled() returns true, then this method will be called prior to
all other methods in this interface to give you the ScanMetrics instance for this scan
operation. |
boolean |
renewLease()
Allow the client to renew the scanner's lease on the server.
|
private void |
resumePrefetch() |
private void |
stopPrefetch(AdvancedScanResultConsumer.ScanController controller) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waititerator, nextforEach, spliteratorprivate static final org.slf4j.Logger LOG
private final AsyncTable<AdvancedScanResultConsumer> rawTable
private final long maxCacheSize
private ScanMetrics scanMetrics
private long cacheSize
private boolean closed
private AdvancedScanResultConsumer.ScanResumer resumer
public AsyncTableResultScanner(AsyncTable<AdvancedScanResultConsumer> table, Scan scan, long maxCacheSize)
private void addToCache(Result result)
private void stopPrefetch(AdvancedScanResultConsumer.ScanController controller)
public void onNext(Result[] results, AdvancedScanResultConsumer.ScanController controller)
AdvancedScanResultConsumeronNext in interface AdvancedScanResultConsumerresults - 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.public void onHeartbeat(AdvancedScanResultConsumer.ScanController controller)
AdvancedScanResultConsumerAdvancedScanResultConsumer.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.
onHeartbeat in interface AdvancedScanResultConsumercontroller - 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.public void onError(Throwable error)
ScanResultConsumerBase
We will not call ScanResultConsumerBase.onComplete() after calling ScanResultConsumerBase.onError(Throwable).
onError in interface ScanResultConsumerBasepublic void onComplete()
ScanResultConsumerBaseonComplete in interface ScanResultConsumerBasepublic void onScanMetricsCreated(ScanMetrics scanMetrics)
ScanResultConsumerBasescan.isScanMetricsEnabled() returns true, then this method will be called prior to
all other methods in this interface to give you the ScanMetrics instance for this scan
operation. The ScanMetrics instance will be updated on-the-fly during the scan, you can
store it somewhere to get the metrics at any time if you want.onScanMetricsCreated in interface ScanResultConsumerBaseprivate void resumePrefetch()
public Result next() throws IOException
ResultScannernext in interface ResultScannerIOException - epublic void close()
ResultScannerclose in interface Closeableclose in interface AutoCloseableclose in interface ResultScannerpublic boolean renewLease()
ResultScannerrenewLease in interface ResultScannerboolean isSuspended()
public ScanMetrics getScanMetrics()
getScanMetrics in interface ResultScannernull if we do not enable metrics.Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.