Package org.apache.hadoop.hbase.client
Class Query
java.lang.Object
org.apache.hadoop.hbase.client.Operation
org.apache.hadoop.hbase.client.OperationWithAttributes
org.apache.hadoop.hbase.client.Query
- All Implemented Interfaces:
Attributes
Base class for HBase read operations; e.g. Scan and Get.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Consistency
protected Filter
private static final String
protected Boolean
protected int
Fields inherited from class org.apache.hadoop.hbase.client.OperationWithAttributes
ID_ATRIBUTE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the logical value indicating whether on-demand CF loading should be allowed.byte[]
getACL()
Returns The serialized ACL for this operation, or null if noneReturns The authorizations this Query is associated with.Returns A map of column families to time rangesReturns the consistency level for this operationReturns The isolation level of this query.Get the raw loadColumnFamiliesOnDemand setting; if it's not set, can be null.int
Returns region replica id where Query will fetch data from.setACL
(String user, Permission perms) Set the ACL for the operation.setACL
(Map<String, Permission> perms) Set the ACL for the operation.setAuthorizations
(Authorizations authorizations) Sets the authorizations to be used by this QuerysetColumnFamilyTimeRange
(byte[] cf, long minStamp, long maxStamp) Get versions of columns only within the specified timestamp range, [minStamp, maxStamp) on a per CF bases.setConsistency
(Consistency consistency) Sets the consistency level for this operationApply the specified server-side filter when performing the Query.setIsolationLevel
(IsolationLevel level) Set the isolation level for this query.setLoadColumnFamiliesOnDemand
(boolean value) Set the value indicating whether loading CFs on demand should be allowed (cluster default is false).setReplicaId
(int Id) Specify region replica id where Query will fetch data from.Methods inherited from class org.apache.hadoop.hbase.client.OperationWithAttributes
getAttribute, getAttributeSize, getAttributesMap, getId, getPriority, setAttribute, setId, setPriority
-
Field Details
-
ISOLATION_LEVEL
- See Also:
-
filter
-
targetReplicaId
-
consistency
-
colFamTimeRangeMap
-
loadColumnFamiliesOnDemand
-
-
Constructor Details
-
Query
public Query()
-
-
Method Details
-
getFilter
-
setFilter
Apply the specified server-side filter when performing the Query. OnlyFilter.filterCell(org.apache.hadoop.hbase.Cell)
is called AFTER all tests for ttl, column match, deletes and column family's max versions have been run.- Parameters:
filter
- filter to run on the server- Returns:
- this for invocation chaining
-
setAuthorizations
Sets the authorizations to be used by this Query -
getAuthorizations
Returns The authorizations this Query is associated with. n- Throws:
DeserializationException
-
getACL
Returns The serialized ACL for this operation, or null if none -
setACL
Set the ACL for the operation.- Parameters:
user
- User short nameperms
- Permissions for the user
-
setACL
Set the ACL for the operation.- Parameters:
perms
- A map of permissions for a user or users
-
getConsistency
Returns the consistency level for this operation- Returns:
- the consistency level
-
setConsistency
Sets the consistency level for this operation- Parameters:
consistency
- the consistency level
-
setReplicaId
Specify region replica id where Query will fetch data from. Use this together withsetConsistency(Consistency)
passingConsistency.TIMELINE
to read data from a specific replicaId.
Expert: This is an advanced API exposed. Only use it if you know what you are doing -
getReplicaId
Returns region replica id where Query will fetch data from.- Returns:
- region replica id or -1 if not set.
-
setIsolationLevel
Set the isolation level for this query. If the isolation level is set to READ_UNCOMMITTED, then this query will return data from committed and uncommitted transactions. If the isolation level is set to READ_COMMITTED, then this query will return data from committed transactions only. If a isolation level is not explicitly set on a Query, then it is assumed to be READ_COMMITTED.- Parameters:
level
- IsolationLevel for this query
-
getIsolationLevel
Returns The isolation level of this query. If no isolation level was set for this query object, then it returns READ_COMMITTED. -
setLoadColumnFamiliesOnDemand
Set the value indicating whether loading CFs on demand should be allowed (cluster default is false). On-demand CF loading doesn't load column families until necessary, e.g. if you filter on one column, the other column family data will be loaded only for the rows that are included in result, not all rows like in normal case. With column-specific filters, like SingleColumnValueFilter w/filterIfMissing == true, this can deliver huge perf gains when there's a cf with lots of data; however, it can also lead to some inconsistent results, as follows: - if someone does a concurrent update to both column families in question you may get a row that never existed, e.g. for { rowKey = 5, { cat_videos => 1 }, { video => "my cat" } } someone puts rowKey 5 with { cat_videos => 0 }, { video => "my dog" }, concurrent scan filtering on "cat_videos == 1" can get { rowKey = 5, { cat_videos => 1 }, { video => "my dog" } }. - if there's a concurrent split and you have more than 2 column families, some rows may be missing some column families. -
getLoadColumnFamiliesOnDemandValue
Get the raw loadColumnFamiliesOnDemand setting; if it's not set, can be null. -
doLoadColumnFamiliesOnDemand
Get the logical value indicating whether on-demand CF loading should be allowed. -
setColumnFamilyTimeRange
Get versions of columns only within the specified timestamp range, [minStamp, maxStamp) on a per CF bases. Note, default maximum versions to return is 1. If your time range spans more than one version and you want all versions returned, up the number of versions beyond the default. Column Family time ranges take precedence over the global time range.- Parameters:
cf
- the column family for which you want to restrictminStamp
- minimum timestamp value, inclusivemaxStamp
- maximum timestamp value, exclusive
-
getColumnFamilyTimeRange
Returns A map of column families to time ranges
-