org.apache.hadoop.hbase.client
Class Scan

java.lang.Object
  extended by org.apache.hadoop.hbase.client.Scan
All Implemented Interfaces:
org.apache.hadoop.io.Writable

public class Scan
extends Object
implements org.apache.hadoop.io.Writable

Used to perform Scan operations.

All operations are identical to Get with the exception of instantiation. Rather than specifying a single row, an optional startRow and stopRow may be defined. If rows are not specified, the Scanner will iterate over all rows.

To scan everything for each row, instantiate a Scan object.

To modify scanner caching for just this scan, use setCaching.

To further define the scope of what to get when scanning, perform additional methods as outlined below.

To get all columns from specific families, execute addFamily for each family to retrieve.

To get specific columns, execute addColumn for each column to retrieve.

To only retrieve columns within a specific range of version timestamps, execute setTimeRange.

To only retrieve columns with a specific timestamp, execute setTimestamp.

To limit the number of versions of each column to be returned, execute setMaxVersions.

To add a filter, execute setFilter.


Constructor Summary
Scan()
          Create a Scan operation across all rows.
Scan(byte[] startRow)
          Create a Scan operation starting at the specified row.
Scan(byte[] startRow, byte[] stopRow)
          Create a Scan operation for the range of rows specified.
Scan(byte[] startRow, Filter filter)
           
Scan(Scan scan)
          Creates a new instance of this class while copying all values.
 
Method Summary
 Scan addColumn(byte[] familyAndQualifier)
          Parses a combined family and qualifier and adds either both or just the family in case there is not qualifier.
 Scan addColumn(byte[] family, byte[] qualifier)
          Get the column from the specified family with the specified qualifier.
 Scan addColumns(byte[][] columns)
          Adds an array of columns specified using old format, family:qualifier.
 Scan addColumns(String columns)
          Convenience method to help parse old style (or rather user entry on the command line) column definitions, e.g.
 Scan addFamily(byte[] family)
          Get all columns from the specified family.
 int getCaching()
           
 byte[][] getFamilies()
           
 Map<byte[],NavigableSet<byte[]>> getFamilyMap()
          Getting the familyMap
 Filter getFilter()
           
 String getInputColumns()
          Helps to convert the binary column families and qualifiers to a text representation, e.g.
 int getMaxVersions()
           
 RowFilterInterface getOldFilter()
          Deprecated.  
 byte[] getStartRow()
           
 byte[] getStopRow()
           
 TimeRange getTimeRange()
           
 boolean hasFamilies()
           
 boolean hasFilter()
           
 int numFamilies()
           
 void readFields(DataInput in)
           
 void setCaching(int caching)
          Set the number of rows for caching that will be passed to scanners.
 Scan setFamilyMap(Map<byte[],NavigableSet<byte[]>> familyMap)
          Setting the familyMap
 Scan setFilter(Filter filter)
          Apply the specified server-side filter when performing the Scan.
 Scan setMaxVersions()
          Get all available versions.
 Scan setMaxVersions(int maxVersions)
          Get up to the specified number of versions of each column.
 Scan setOldFilter(RowFilterInterface filter)
          Deprecated.  
 Scan setStartRow(byte[] startRow)
          Set the start row.
 Scan setStopRow(byte[] stopRow)
          Set the stop row.
 Scan setTimeRange(long minStamp, long maxStamp)
          Get versions of columns only within the specified timestamp range, [minStamp, maxStamp).
 Scan setTimeStamp(long timestamp)
          Get versions of columns with the specified timestamp.
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Scan

public Scan()
Create a Scan operation across all rows.


Scan

public Scan(byte[] startRow,
            Filter filter)

Scan

public Scan(byte[] startRow)
Create a Scan operation starting at the specified row.

If the specified row does not exist, the Scanner will start from the next closest row after the specified row.

Parameters:
startRow - row to start scanner at or after

Scan

public Scan(byte[] startRow,
            byte[] stopRow)
Create a Scan operation for the range of rows specified.

Parameters:
startRow - row to start scanner at or after (inclusive)
stopRow - row to stop scanner before (exclusive)

Scan

public Scan(Scan scan)
     throws IOException
Creates a new instance of this class while copying all values.

Parameters:
scan - The scan instance to copy from.
Throws:
IOException - When copying the values fails.
Method Detail

addFamily

public Scan addFamily(byte[] family)
Get all columns from the specified family.

Overrides previous calls to addColumn for this family.

Parameters:
family - family name

addColumn

public Scan addColumn(byte[] family,
                      byte[] qualifier)
Get the column from the specified family with the specified qualifier.

Overrides previous calls to addFamily for this family.

Parameters:
family - family name
qualifier - column qualifier

addColumn

public Scan addColumn(byte[] familyAndQualifier)
Parses a combined family and qualifier and adds either both or just the family in case there is not qualifier. This assumes the older colon divided notation, e.g. "data:contents" or "meta:".

Note: It will through an error when the colon is missing.

Parameters:
familyAndQualifier -
Returns:
A reference to this instance.
Throws:
IllegalArgumentException - When the colon is missing.

addColumns

public Scan addColumns(byte[][] columns)
Adds an array of columns specified using old format, family:qualifier.

Overrides previous calls to addFamily for any families in the input.

Parameters:
columns - array of columns, formatted as
family:qualifier

addColumns

public Scan addColumns(String columns)
Convenience method to help parse old style (or rather user entry on the command line) column definitions, e.g. "data:contents mime:". The columns must be space delimited and always have a colon (":") to denote family and qualifier.

Parameters:
columns - The columns to parse.
Returns:
A reference to this instance.

getInputColumns

public String getInputColumns()
Helps to convert the binary column families and qualifiers to a text representation, e.g. "data:mimetype data:contents meta:". Binary values are properly encoded using Bytes.toBytesBinary(String).

Returns:
The columns in an old style string format.

setTimeRange

public Scan setTimeRange(long minStamp,
                         long maxStamp)
                  throws IOException
Get versions of columns only within the specified timestamp range, [minStamp, maxStamp).

Parameters:
minStamp - minimum timestamp value, inclusive
maxStamp - maximum timestamp value, exclusive
Throws:
IOException - if invalid time range

setTimeStamp

public Scan setTimeStamp(long timestamp)
Get versions of columns with the specified timestamp.

Parameters:
timestamp - version timestamp

setStartRow

public Scan setStartRow(byte[] startRow)
Set the start row.

Parameters:
startRow -

setStopRow

public Scan setStopRow(byte[] stopRow)
Set the stop row.

Parameters:
stopRow -

setMaxVersions

public Scan setMaxVersions()
Get all available versions.


setMaxVersions

public Scan setMaxVersions(int maxVersions)
Get up to the specified number of versions of each column.

Parameters:
maxVersions - maximum versions for each column

setCaching

public void setCaching(int caching)
Set the number of rows for caching that will be passed to scanners. If not set, the default setting from HTable.getScannerCaching() will apply. Higher caching values will enable faster scanners but will use more memory.

Parameters:
caching - the number of rows for caching

setFilter

public Scan setFilter(Filter filter)
Apply the specified server-side filter when performing the Scan.

Parameters:
filter - filter to run on the server

setOldFilter

public Scan setOldFilter(RowFilterInterface filter)
Deprecated. 

Set an old-style filter interface to use. Note: not all features of the old style filters are supported.

Parameters:
filter -
Returns:
The scan instance.

setFamilyMap

public Scan setFamilyMap(Map<byte[],NavigableSet<byte[]>> familyMap)
Setting the familyMap

Parameters:
familyMap -

getFamilyMap

public Map<byte[],NavigableSet<byte[]>> getFamilyMap()
Getting the familyMap

Returns:
familyMap

numFamilies

public int numFamilies()
Returns:
the number of families in familyMap

hasFamilies

public boolean hasFamilies()
Returns:
true if familyMap is non empty, false otherwise

getFamilies

public byte[][] getFamilies()
Returns:
the keys of the familyMap

getStartRow

public byte[] getStartRow()
Returns:
the startrow

getStopRow

public byte[] getStopRow()
Returns:
the stoprow

getMaxVersions

public int getMaxVersions()
Returns:
the max number of versions to fetch

getCaching

public int getCaching()
Returns:
caching the number of rows fetched when calling next on a scanner

getTimeRange

public TimeRange getTimeRange()
Returns:
TimeRange

getFilter

public Filter getFilter()
Returns:
RowFilter

getOldFilter

public RowFilterInterface getOldFilter()
Deprecated. 

Get the old style filter, if there is one.

Returns:
null or instance

hasFilter

public boolean hasFilter()
Returns:
true is a filter has been specified, false if not

toString

public String toString()
Overrides:
toString in class Object
Returns:
String

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException


Copyright © 2009 The Apache Software Foundation