Package org.apache.hadoop.hbase.client
Class ClientScanner
java.lang.Object
org.apache.hadoop.hbase.client.AbstractClientScanner
org.apache.hadoop.hbase.client.ClientScanner
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<Result>
,ResultScanner
- Direct Known Subclasses:
ClientSimpleScanner
,ReversedClientScanner
Implements the scanner interface for the HBase client. If there are multiple regions in a table,
this scanner will iterate through them all.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected ScannerCallableWithReplicas
protected RpcRetryingCaller<Result[]>
protected boolean
protected org.apache.hadoop.conf.Configuration
private final ClusterConnection
protected HRegionInfo
protected long
protected Result
private static final org.slf4j.Logger
protected final long
protected final ExecutorService
protected final int
protected final int
private int
protected RpcControllerFactory
protected final Scan
private final Scan
protected boolean
protected final int
private final ScanResultCache
protected final io.opentelemetry.api.trace.Span
protected final TableName
private final boolean
Fields inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
scanMetrics
-
Constructor Summary
ConstructorDescriptionClientScanner
(org.apache.hadoop.conf.Configuration conf, Scan scan, Scan scanForMetrics, TableName tableName, ClusterConnection connection, RpcRetryingCallerFactory rpcFactory, RpcControllerFactory controllerFactory, ExecutorService pool, int scanReadRpcTimeout, int scannerTimeout, int primaryOperationTimeout, ConnectionConfiguration connectionConfiguration, Map<String, byte[]> requestAttributes) Create a new ClientScanner for the specified table Note that the passedScan
's start row maybe changed changed. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addEstimatedSize
(long estimatedHeapSizeOfResult) private Result[]
call
(ScannerCallableWithReplicas callable, RpcRetryingCaller<Result[]> caller, int scannerTimeout, boolean updateCurrentRegion) void
close()
Closes the scanner and releases any resources it has allocatedprivate void
private void
closeScannerIfExhausted
(boolean exhausted) protected abstract ScannerCallable
Will be called in moveToNextRegion to create ScannerCallable.int
int
protected int
protected org.apache.hadoop.conf.Configuration
getConf()
protected ClusterConnection
protected long
protected ExecutorService
getPool()
protected int
protected int
protected Scan
getScan()
protected int
protected final int
protected TableName
getTable()
protected long
private void
handleScanError
(DoNotRetryIOException e, org.apache.commons.lang3.mutable.MutableBoolean retryAfterOutOfOrderException, int retriesLeft) protected void
protected void
(package private) boolean
protected void
Contact the servers to load moreResult
s in the cache.protected boolean
Close the previous scanner and create a new ScannerCallable for the next scanner.next()
Grab the next row's worth of values.protected Result
private boolean
regionExhausted
(Result[] values) boolean
Allow the client to renew the scanner's lease on the server.private boolean
protected abstract boolean
Will be called in moveToNextRegion when currentRegion is null.protected void
Publish the scan metrics.Methods inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
getScanMetrics, initScanMetrics
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
-
scan
-
scanForMetrics
-
closed
-
currentRegion
-
callable
-
cache
-
scanResultCache
-
caching
-
lastNext
-
lastResult
-
maxScannerResultSize
-
connection
-
tableName
-
readRpcTimeout
-
scannerTimeout
-
useScannerTimeoutForNextCalls
-
scanMetricsPublished
-
caller
-
rpcControllerFactory
-
conf
-
span
-
-
retries
-
pool
-
requestAttributes
-
-
Constructor Details
-
ClientScanner
public ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, Scan scanForMetrics, TableName tableName, ClusterConnection connection, RpcRetryingCallerFactory rpcFactory, RpcControllerFactory controllerFactory, ExecutorService pool, int scanReadRpcTimeout, int scannerTimeout, int primaryOperationTimeout, ConnectionConfiguration connectionConfiguration, Map<String, byte[]> requestAttributes) throws IOExceptionCreate a new ClientScanner for the specified table Note that the passedScan
's start row maybe changed changed.- Parameters:
conf
- TheConfiguration
to use.scan
-Scan
to use in this scannertableName
- The table that we wish to scanconnection
- Connection identifying the cluster- Throws:
IOException
-
-
Method Details
-
getScanReplicaId
-
getConnection
-
getTable
-
getRetries
-
getScannerTimeout
-
getConf
-
getScan
-
getPool
-
getPrimaryOperationTimeout
-
getCaching
-
getTimestamp
-
getMaxResultSize
-
closeScanner
- Throws:
IOException
-
setNewStartKey
Will be called in moveToNextRegion when currentRegion is null. Abstract because for normal scan, we will start next scan from the endKey of the currentRegion, and for reversed scan, we will start next scan from the startKey of the currentRegion.- Returns:
false
if we have reached the stop row. Otherwisetrue
.
-
createScannerCallable
Will be called in moveToNextRegion to create ScannerCallable. Abstract because for reversed scan we need to create a ReversedScannerCallable. -
moveToNextRegion
Close the previous scanner and create a new ScannerCallable for the next scanner.Marked as protected only because TestClientScanner need to override this method.
- Returns:
- false if we should terminate the scan. Otherwise
-
isAnyRPCcancelled
boolean isAnyRPCcancelled() -
call
private Result[] call(ScannerCallableWithReplicas callable, RpcRetryingCaller<Result[]> caller, int scannerTimeout, boolean updateCurrentRegion) throws IOException - Throws:
IOException
-
writeScanMetrics
Publish the scan metrics. For now, we use scan.setAttribute to pass the metrics back to the application or TableInputFormat.Later, we could push it to other systems. We don't use metrics framework because it doesn't support multi-instances of the same metrics on the same machine; for scan/map reduce scenarios, we will have multiple scans running at the same time. By default, scan metrics are disabled; if the application wants to collect them, this behavior can be turned on by calling callingScan.setScanMetricsEnabled(boolean)
-
initSyncCache
-
nextWithSyncCache
- Throws:
IOException
-
getCacheSize
-
scanExhausted
-
regionExhausted
-
closeScannerIfExhausted
- Throws:
IOException
-
handleScanError
private void handleScanError(DoNotRetryIOException e, org.apache.commons.lang3.mutable.MutableBoolean retryAfterOutOfOrderException, int retriesLeft) throws DoNotRetryIOException - Throws:
DoNotRetryIOException
-
loadCache
Contact the servers to load moreResult
s in the cache.- Throws:
IOException
-
addEstimatedSize
-
getCacheCount
-
close
Description copied from interface:ResultScanner
Closes the scanner and releases any resources it has allocated -
renewLease
Description copied from interface:ResultScanner
Allow the client to renew the scanner's lease on the server.- Returns:
- true if the lease was successfully renewed, false otherwise.
-
initCache
-
next
Description copied from interface:ResultScanner
Grab the next row's worth of values. The scanner will return a Result.- Returns:
- Result object if there is another row, null if the scanner is exhausted.
- Throws:
IOException
- e
-