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
Modifier and TypeFieldDescriptionprivate long
private boolean
private Throwable
private static final org.slf4j.Logger
private final long
private final Scan
private ScanMetrics
private io.opentelemetry.api.trace.Span
private final TableName
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
addToCache
(Result result) void
close()
Closes the scanner and releases any resources it has allocated(package private) int
Returns the scan metrics, ornull
if we do not enable metrics.(package private) io.opentelemetry.api.trace.Span
getSpan()
(package private) boolean
next()
Grab the next row's worth of values.void
Indicate that the scan operation is completed normally.void
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 callAdvancedScanResultConsumer.onNext(Result[], ScanController)
.void
onNext
(Result[] results, AdvancedScanResultConsumer.ScanController controller) Indicate that we have receive some data.void
onScanMetricsCreated
(ScanMetrics scanMetrics) Ifscan.isScanMetricsEnabled()
returns true, then this method will be called prior to all other methods in this interface to give you theScanMetrics
instance for this scan operation.boolean
Allow the client to renew the scanner's lease on the server.private void
(package private) void
setSpan
(io.opentelemetry.api.trace.Span span) private void
private void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods 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:AdvancedScanResultConsumer
Indicate that we have receive some data.- Specified by:
onNext
in interfaceAdvancedScanResultConsumer
- 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
Description copied from interface:AdvancedScanResultConsumer
Indicate 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:
onHeartbeat
in interfaceAdvancedScanResultConsumer
- 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.
-
onError
Description copied from interface:ScanResultConsumerBase
Indicate that we hit an unrecoverable error and the scan operation is terminated.We will not call
ScanResultConsumerBase.onComplete()
after callingScanResultConsumerBase.onError(Throwable)
.- Specified by:
onError
in interfaceScanResultConsumerBase
-
onComplete
Description copied from interface:ScanResultConsumerBase
Indicate that the scan operation is completed normally.- Specified by:
onComplete
in interfaceScanResultConsumerBase
-
onScanMetricsCreated
Description copied from interface:ScanResultConsumerBase
Ifscan.isScanMetricsEnabled()
returns true, then this method will be called prior to all other methods in this interface to give you theScanMetrics
instance for this scan operation. TheScanMetrics
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.- Specified by:
onScanMetricsCreated
in interfaceScanResultConsumerBase
-
resumePrefetch
-
terminateResumerIfPossible
-
next
Description copied from interface:ResultScanner
Grab the next row's worth of values. The scanner will return a Result.- Specified by:
next
in interfaceResultScanner
- Returns:
- Result object if there is another row, null if the scanner is exhausted.
- Throws:
IOException
- e
-
close
Description copied from interface:ResultScanner
Closes the scanner and releases any resources it has allocated- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceResultScanner
-
renewLease
Description copied from interface:ResultScanner
Allow the client to renew the scanner's lease on the server.- Specified by:
renewLease
in interfaceResultScanner
- Returns:
- true if the lease was successfully renewed, false otherwise.
-
isSuspended
boolean isSuspended() -
getScanMetrics
Description copied from interface:ResultScanner
Returns the scan metrics, ornull
if we do not enable metrics.- Specified by:
getScanMetrics
in interfaceResultScanner
-
getCacheSize
int getCacheSize()
-