org.apache.hadoop.hbase.client
Class Get

java.lang.Object
  extended by org.apache.hadoop.hbase.client.Operation
      extended by org.apache.hadoop.hbase.client.OperationWithAttributes
          extended by org.apache.hadoop.hbase.client.Query
              extended by org.apache.hadoop.hbase.client.Get
All Implemented Interfaces:
Comparable<Row>, Attributes, Row

@InterfaceAudience.Public
@InterfaceStability.Stable
public class Get
extends Query
implements Row, Comparable<Row>

Used to perform Get operations on a single row.

To get everything for a row, instantiate a Get object with the row to get. To further narrow the scope of what to Get, use the methods 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, call setFilter.


Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.client.Query
filter
 
Fields inherited from class org.apache.hadoop.hbase.client.OperationWithAttributes
ID_ATRIBUTE
 
Constructor Summary
Get(byte[] row)
          Create a Get operation for the specified row.
Get(Get get)
          Copy-constructor
 
Method Summary
 Get addColumn(byte[] family, byte[] qualifier)
          Get the column from the specific family with the specified qualifier.
 Get addFamily(byte[] family)
          Get all columns from the specified family.
 int compareTo(Row other)
           
 boolean equals(Object obj)
           
 Set<byte[]> familySet()
          Method for retrieving the keys in the familyMap
 boolean getCacheBlocks()
          Get whether blocks should be cached for this Get.
 Map<byte[],NavigableSet<byte[]>> getFamilyMap()
          Method for retrieving the get's familyMap
 Map<String,Object> getFingerprint()
          Compile the table and column family (i.e.
 int getMaxResultsPerColumnFamily()
          Method for retrieving the get's maximum number of values to return per Column Family
 int getMaxVersions()
          Method for retrieving the get's maximum number of version
 byte[] getRow()
          Method for retrieving the get's row
 int getRowOffsetPerColumnFamily()
          Method for retrieving the get's offset per row per column family (#kvs to be skipped)
 TimeRange getTimeRange()
          Method for retrieving the get's TimeRange
 boolean hasFamilies()
          Method for checking if any families have been inserted into this Get
 int hashCode()
           
 boolean isCheckExistenceOnly()
           
 boolean isClosestRowBefore()
           
 int numFamilies()
          Method for retrieving the number of families to get from
 void setCacheBlocks(boolean cacheBlocks)
          Set whether blocks should be cached for this Get.
 void setCheckExistenceOnly(boolean checkExistenceOnly)
           
 void setClosestRowBefore(boolean closestRowBefore)
           
 Get setFilter(Filter filter)
          Apply the specified server-side filter when performing the Query.
 Get setMaxResultsPerColumnFamily(int limit)
          Set the maximum number of values to return per row per Column Family
 Get setMaxVersions()
          Get all available versions.
 Get setMaxVersions(int maxVersions)
          Get up to the specified number of versions of each column.
 Get setRowOffsetPerColumnFamily(int offset)
          Set offset for the row per Column Family.
 Get setTimeRange(long minStamp, long maxStamp)
          Get versions of columns only within the specified timestamp range, [minStamp, maxStamp).
 Get setTimeStamp(long timestamp)
          Get versions of columns with the specified timestamp.
 Map<String,Object> toMap(int maxCols)
          Compile the details beyond the scope of getFingerprint (row, columns, timestamps, etc.) into a Map along with the fingerprinted information.
 
Methods inherited from class org.apache.hadoop.hbase.client.Query
getACL, getACLStrategy, getAuthorizations, getFilter, getIsolationLevel, setACL, setACL, setACLStrategy, setAuthorizations, setIsolationLevel
 
Methods inherited from class org.apache.hadoop.hbase.client.OperationWithAttributes
getAttribute, getAttributeSize, getAttributesMap, getId, setAttribute, setId
 
Methods inherited from class org.apache.hadoop.hbase.client.Operation
toJSON, toJSON, toMap, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Get

public Get(byte[] row)
Create a Get operation for the specified row.

If no further operations are done, this will get the latest version of all columns in all families of the specified row.

Parameters:
row - row key

Get

public Get(Get get)
Copy-constructor

Parameters:
get -
Method Detail

isCheckExistenceOnly

public boolean isCheckExistenceOnly()

setCheckExistenceOnly

public void setCheckExistenceOnly(boolean checkExistenceOnly)

isClosestRowBefore

public boolean isClosestRowBefore()

setClosestRowBefore

public void setClosestRowBefore(boolean closestRowBefore)

addFamily

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

Overrides previous calls to addColumn for this family.

Parameters:
family - family name
Returns:
the Get object

addColumn

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

Overrides previous calls to addFamily for this family.

Parameters:
family - family name
qualifier - column qualifier
Returns:
the Get objec

setTimeRange

public Get 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
Returns:
this for invocation chaining
Throws:
IOException - if invalid time range

setTimeStamp

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

Parameters:
timestamp - version timestamp
Returns:
this for invocation chaining
Throws:
IOException

setMaxVersions

public Get setMaxVersions()
Get all available versions.

Returns:
this for invocation chaining

setMaxVersions

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

Parameters:
maxVersions - maximum versions for each column
Returns:
this for invocation chaining
Throws:
IOException - if invalid number of versions

setMaxResultsPerColumnFamily

public Get setMaxResultsPerColumnFamily(int limit)
Set the maximum number of values to return per row per Column Family

Parameters:
limit - the maximum number of values returned / row / CF
Returns:
this for invocation chaining

setRowOffsetPerColumnFamily

public Get setRowOffsetPerColumnFamily(int offset)
Set offset for the row per Column Family. This offset is only within a particular row/CF combination. It gets reset back to zero when we move to the next row or CF.

Parameters:
offset - is the number of kvs that will be skipped.
Returns:
this for invocation chaining

setFilter

public Get setFilter(Filter filter)
Description copied from class: Query
Apply the specified server-side filter when performing the Query. Only Filter.filterKeyValue(Cell) is called AFTER all tests for ttl, column match, deletes and max versions have been run.

Overrides:
setFilter in class Query
Parameters:
filter - filter to run on the server
Returns:
this for invocation chaining

setCacheBlocks

public void setCacheBlocks(boolean cacheBlocks)
Set whether blocks should be cached for this Get.

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).

Parameters:
cacheBlocks - if false, default settings are overridden and blocks will not be cached

getCacheBlocks

public boolean getCacheBlocks()
Get whether blocks should be cached for this Get.

Returns:
true if default caching should be used, false if blocks should not be cached

getRow

public byte[] getRow()
Method for retrieving the get's row

Specified by:
getRow in interface Row
Returns:
row

getMaxVersions

public int getMaxVersions()
Method for retrieving the get's maximum number of version

Returns:
the maximum number of version to fetch for this get

getMaxResultsPerColumnFamily

public int getMaxResultsPerColumnFamily()
Method for retrieving the get's maximum number of values to return per Column Family

Returns:
the maximum number of values to fetch per CF

getRowOffsetPerColumnFamily

public int getRowOffsetPerColumnFamily()
Method for retrieving the get's offset per row per column family (#kvs to be skipped)

Returns:
the row offset

getTimeRange

public TimeRange getTimeRange()
Method for retrieving the get's TimeRange

Returns:
timeRange

familySet

public Set<byte[]> familySet()
Method for retrieving the keys in the familyMap

Returns:
keys in the current familyMap

numFamilies

public int numFamilies()
Method for retrieving the number of families to get from

Returns:
number of families

hasFamilies

public boolean hasFamilies()
Method for checking if any families have been inserted into this Get

Returns:
true if familyMap is non empty false otherwise

getFamilyMap

public Map<byte[],NavigableSet<byte[]>> getFamilyMap()
Method for retrieving the get's familyMap

Returns:
familyMap

getFingerprint

public Map<String,Object> getFingerprint()
Compile the table and column family (i.e. schema) information into a String. Useful for parsing and aggregation by debugging, logging, and administration tools.

Specified by:
getFingerprint in class Operation
Returns:
Map

toMap

public Map<String,Object> toMap(int maxCols)
Compile the details beyond the scope of getFingerprint (row, columns, timestamps, etc.) into a Map along with the fingerprinted information. Useful for debugging, logging, and administration tools.

Specified by:
toMap in class Operation
Parameters:
maxCols - a limit on the number of columns output prior to truncation
Returns:
Map

compareTo

public int compareTo(Row other)
Specified by:
compareTo in interface Comparable<Row>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


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