org.apache.hadoop.hbase.client
Class ClientScanner

java.lang.Object
  extended by org.apache.hadoop.hbase.client.AbstractClientScanner
      extended by org.apache.hadoop.hbase.client.ClientScanner
All Implemented Interfaces:
Closeable, Iterable<Result>, ResultScanner
Direct Known Subclasses:
ClientSmallScanner, ReversedClientScanner

@InterfaceAudience.Public
@InterfaceStability.Stable
public class ClientScanner
extends AbstractClientScanner

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
protected  LinkedList<Result> cache
           
protected  int caching
           
protected  ScannerCallable callable
           
protected  RpcRetryingCaller<Result[]> caller
           
protected  boolean closed
           
protected  HRegionInfo currentRegion
           
protected  long lastNext
           
protected  Result lastResult
           
protected  long maxScannerResultSize
           
protected  RpcControllerFactory rpcControllerFactory
           
protected  Scan scan
           
protected  boolean scanMetricsPublished
           
protected  int scannerTimeout
           
 
Fields inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
scanMetrics
 
Constructor Summary
ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, byte[] tableName)
          Deprecated. Use ClientScanner(Configuration, Scan, TableName)
ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, byte[] tableName, HConnection connection)
          Deprecated. Use ClientScanner(Configuration, Scan, TableName, HConnection)
ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, TableName tableName)
          Deprecated. 
ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, TableName tableName, HConnection connection)
          Create a new ClientScanner for the specified table Note that the passed Scan's start row maybe changed changed.
ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, TableName tableName, HConnection connection, RpcRetryingCallerFactory rpcFactory)
          Deprecated. Use ClientScanner(Configuration, Scan, TableName, HConnection, RpcRetryingCallerFactory, RpcControllerFactory) instead
ClientScanner(org.apache.hadoop.conf.Configuration conf, Scan scan, TableName tableName, HConnection connection, RpcRetryingCallerFactory rpcFactory, RpcControllerFactory controllerFactory)
          Create a new ClientScanner for the specified table Note that the passed Scan's start row maybe changed changed.
 
Method Summary
protected  boolean checkScanStopRow(byte[] endKey)
           
 void close()
          Closes the scanner and releases any resources it has allocated
 int getCacheSize()
           
protected  HConnection getConnection()
           
protected  long getMaxResultSize()
           
protected  Scan getScan()
           
protected  ScannerCallable getScannerCallable(byte[] localStartKey, int nbRows)
           
protected  TableName getTable()
           
protected  byte[] getTableName()
          Deprecated. Since 0.96.0; use getTable()
protected  long getTimestamp()
           
protected  void initializeScannerInConstruction()
           
protected  void loadCache()
          Contact the servers to load more Results in the cache.
 Result next()
          Grab the next row's worth of values.
protected  boolean nextScanner(int nbRows, boolean done)
           
 boolean renewLease()
          Allow the client to renew the scanner's lease on the server.
protected  void writeScanMetrics()
          Publish the scan metrics.
 
Methods inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
getScanMetrics, initScanMetrics, iterator, next
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scan

protected Scan scan

closed

protected boolean closed

currentRegion

protected HRegionInfo currentRegion

callable

protected ScannerCallable callable

cache

protected final LinkedList<Result> cache

caching

protected final int caching

lastNext

protected long lastNext

lastResult

protected Result lastResult

maxScannerResultSize

protected final long maxScannerResultSize

scannerTimeout

protected final int scannerTimeout

scanMetricsPublished

protected boolean scanMetricsPublished

caller

protected RpcRetryingCaller<Result[]> caller

rpcControllerFactory

protected RpcControllerFactory rpcControllerFactory
Constructor Detail

ClientScanner

@Deprecated
public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                                Scan scan,
                                TableName tableName)
              throws IOException
Deprecated. 

Create a new ClientScanner for the specified table. An HConnection will be retrieved using the passed Configuration. Note that the passed Scan's start row maybe changed changed.

Parameters:
conf - The Configuration to use.
scan - Scan to use in this scanner
tableName - The table that we wish to scan
Throws:
IOException

ClientScanner

@Deprecated
public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                                Scan scan,
                                byte[] tableName)
              throws IOException
Deprecated. Use ClientScanner(Configuration, Scan, TableName)

Throws:
IOException

ClientScanner

public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                     Scan scan,
                     TableName tableName,
                     HConnection connection)
              throws IOException
Create a new ClientScanner for the specified table Note that the passed Scan's start row maybe changed changed.

Parameters:
conf - The Configuration to use.
scan - Scan to use in this scanner
tableName - The table that we wish to scan
connection - Connection identifying the cluster
Throws:
IOException

ClientScanner

@Deprecated
public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                                Scan scan,
                                byte[] tableName,
                                HConnection connection)
              throws IOException
Deprecated. Use ClientScanner(Configuration, Scan, TableName, HConnection)

Throws:
IOException

ClientScanner

@Deprecated
public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                                Scan scan,
                                TableName tableName,
                                HConnection connection,
                                RpcRetryingCallerFactory rpcFactory)
              throws IOException
Deprecated. Use ClientScanner(Configuration, Scan, TableName, HConnection, RpcRetryingCallerFactory, RpcControllerFactory) instead

Throws:
IOException

ClientScanner

public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                     Scan scan,
                     TableName tableName,
                     HConnection connection,
                     RpcRetryingCallerFactory rpcFactory,
                     RpcControllerFactory controllerFactory)
              throws IOException
Create a new ClientScanner for the specified table Note that the passed Scan's start row maybe changed changed.

Parameters:
conf - The Configuration to use.
scan - Scan to use in this scanner
tableName - The table that we wish to scan
connection - Connection identifying the cluster
Throws:
IOException
Method Detail

initializeScannerInConstruction

protected void initializeScannerInConstruction()
                                        throws IOException
Throws:
IOException

getConnection

protected HConnection getConnection()

getTableName

@Deprecated
protected byte[] getTableName()
Deprecated. Since 0.96.0; use getTable()

Returns:
Table name

getTable

protected TableName getTable()

getScan

protected Scan getScan()

getTimestamp

protected long getTimestamp()

getMaxResultSize

protected long getMaxResultSize()

checkScanStopRow

protected boolean checkScanStopRow(byte[] endKey)

nextScanner

protected boolean nextScanner(int nbRows,
                              boolean done)
                       throws IOException
Throws:
IOException

getScannerCallable

@InterfaceAudience.Private
protected ScannerCallable getScannerCallable(byte[] localStartKey,
                                                                       int nbRows)

writeScanMetrics

protected void 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 calling: scan.setAttribute(SCAN_ATTRIBUTES_METRICS_ENABLE, Bytes.toBytes(Boolean.TRUE))


next

public Result next()
            throws IOException
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

getCacheSize

public int getCacheSize()

loadCache

protected void loadCache()
                  throws IOException
Contact the servers to load more Results in the cache.

Throws:
IOException

close

public void close()
Description copied from interface: ResultScanner
Closes the scanner and releases any resources it has allocated


renewLease

public boolean renewLease()
Description copied from class: AbstractClientScanner
Allow the client to renew the scanner's lease on the server.

Specified by:
renewLease in class AbstractClientScanner
Returns:
true if the lease was successfully renewed, false otherwise.


Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.