|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.client.Scan
public class Scan
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
.
Expert: To explicitly disable server-side block caching for this scan,
execute setCacheBlocks(boolean)
.
Field Summary | |
---|---|
protected Map<ImmutableBytesWritable,ImmutableBytesWritable> |
values
|
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(Get get)
Builds a scan object with the same specs as get. |
|
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. |
boolean |
getCacheBlocks()
Get whether blocks should be cached for this Scan. |
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()
|
byte[] |
getValue(byte[] key)
|
String |
getValue(String key)
|
Map<ImmutableBytesWritable,ImmutableBytesWritable> |
getValues()
|
boolean |
hasFamilies()
|
boolean |
hasFilter()
|
boolean |
isGetScan()
|
int |
numFamilies()
|
void |
readFields(DataInput in)
|
void |
remove(byte[] key)
|
void |
setCacheBlocks(boolean cacheBlocks)
Set whether blocks should be cached for this Scan. |
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. |
void |
setValue(byte[] key,
byte[] value)
|
void |
setValue(String key,
String value)
|
String |
toString()
|
void |
write(DataOutput out)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Map<ImmutableBytesWritable,ImmutableBytesWritable> values
Constructor Detail |
---|
public Scan()
public Scan(byte[] startRow, Filter filter)
public Scan(byte[] startRow)
If the specified row does not exist, the Scanner will start from the next closest row after the specified row.
startRow
- row to start scanner at or afterpublic Scan(byte[] startRow, byte[] stopRow)
startRow
- row to start scanner at or after (inclusive)stopRow
- row to stop scanner before (exclusive)public Scan(Scan scan) throws IOException
scan
- The scan instance to copy from.
IOException
- When copying the values fails.public Scan(Get get)
get
- get to model scan afterMethod Detail |
---|
public boolean isGetScan()
public Scan addFamily(byte[] family)
Overrides previous calls to addColumn for this family.
family
- family name
public Scan addColumn(byte[] family, byte[] qualifier)
Overrides previous calls to addFamily for this family.
family
- family namequalifier
- column qualifier
public Scan addColumn(byte[] familyAndQualifier)
Note: It will through an error when the colon is missing.
familyAndQualifier
-
IllegalArgumentException
- When the colon is missing.public Scan addColumns(byte[][] columns)
Overrides previous calls to addFamily for any families in the input.
columns
- array of columns, formatted as family:qualifier
public Scan addColumns(String columns)
columns
- The columns to parse.
public String getInputColumns()
Bytes.toBytesBinary(String)
.
public Scan setTimeRange(long minStamp, long maxStamp) throws IOException
minStamp
- minimum timestamp value, inclusivemaxStamp
- maximum timestamp value, exclusive
IOException
- if invalid time rangesetMaxVersions()
,
setMaxVersions(int)
public Scan setTimeStamp(long timestamp)
timestamp
- version timestampsetMaxVersions()
,
setMaxVersions(int)
public Scan setStartRow(byte[] startRow)
startRow
- public Scan setStopRow(byte[] stopRow)
stopRow
- public Scan setMaxVersions()
public Scan setMaxVersions(int maxVersions)
maxVersions
- maximum versions for each columnpublic void setCaching(int caching)
HTable.getScannerCaching()
will apply.
Higher caching values will enable faster scanners but will use more memory.
caching
- the number of rows for cachingpublic Scan setFilter(Filter filter)
filter
- filter to run on the serverpublic Scan setOldFilter(RowFilterInterface filter)
filter
-
public Scan setFamilyMap(Map<byte[],NavigableSet<byte[]>> familyMap)
familyMap
- public Map<byte[],NavigableSet<byte[]>> getFamilyMap()
public int numFamilies()
public boolean hasFamilies()
public byte[][] getFamilies()
public byte[] getStartRow()
public byte[] getStopRow()
public int getMaxVersions()
public int getCaching()
public TimeRange getTimeRange()
public Filter getFilter()
public RowFilterInterface getOldFilter()
public boolean hasFilter()
public void setCacheBlocks(boolean cacheBlocks)
This is true by default. When true, default settings of the table and family are used (this will never override caching blocks if the block cache is disabled for that family or entirely).
cacheBlocks
- if false, default settings are overridden and blocks
will not be cachedpublic boolean getCacheBlocks()
public byte[] getValue(byte[] key)
key
- The key.
public String getValue(String key)
key
- The key.
public Map<ImmutableBytesWritable,ImmutableBytesWritable> getValues()
public void setValue(byte[] key, byte[] value)
key
- The key.value
- The value.public void setValue(String key, String value)
key
- The key.value
- The value.public void remove(byte[] key)
key
- Key whose key and value we're to remove from HTD parameters.public String toString()
toString
in class Object
public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |