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

@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  RpcRetryingCaller<Result[]> caller
           
protected  boolean closed
           
protected  HRegionInfo currentRegion
           
protected  long lastNext
           
protected  Result lastResult
           
protected  long maxScannerResultSize
           
protected  Scan scan
           
protected  ScanMetrics scanMetrics
           
protected  boolean scanMetricsPublished
           
 
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)
          Create a new ClientScanner for the specified table.
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)
          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
protected  HConnection getConnection()
           
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()
           
 Result next()
          Grab the next row's worth of values.
 Result[] next(int nbRows)
          Get nbRows rows.
protected  void writeScanMetrics()
          Publish the scan metrics.
 
Methods inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
iterator
 
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

cache

protected final LinkedList<Result> cache

caching

protected final int caching

lastNext

protected long lastNext

lastResult

protected Result lastResult

scanMetrics

protected ScanMetrics scanMetrics

maxScannerResultSize

protected final long maxScannerResultSize

scanMetricsPublished

protected boolean scanMetricsPublished

caller

protected RpcRetryingCaller<Result[]> caller
Constructor Detail

ClientScanner

public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                     Scan scan,
                     TableName tableName)
              throws IOException
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

public ClientScanner(org.apache.hadoop.conf.Configuration conf,
                     Scan scan,
                     TableName tableName,
                     HConnection connection,
                     RpcRetryingCallerFactory rpcFactory)
              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()

checkScanStopRow

protected boolean checkScanStopRow(byte[] endKey)

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

next

public Result[] next(int nbRows)
              throws IOException
Get nbRows rows. How many RPCs are made is determined by the Scan.setCaching(int) setting (or hbase.client.scanner.caching in hbase-site.xml).

Parameters:
nbRows - number of rows to return
Returns:
Between zero and nbRows RowResults. Scan is done if returned array is of zero-length (We never return null).
Throws:
IOException

close

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



Copyright © 2013 The Apache Software Foundation. All Rights Reserved.