public final class AnyScan extends Object
Scan
in HBase to reduce the manual conversion between bytes and String/Object.Scan
Modifier and Type | Method and Description |
---|---|
AnyScan |
addColumn(byte[] family,
byte[] qualifier)
Adds the column.
|
AnyScan |
addColumn(String family,
String qualifier)
Adds the column.
|
AnyScan |
addFamily(byte[] family)
Adds the family.
|
AnyScan |
addFamily(String family)
Adds the family.
|
static AnyScan |
create() |
static AnyScan |
createScanFromCursor(org.apache.hadoop.hbase.client.Cursor cursor)
Creates the scan from cursor.
|
boolean |
doLoadColumnFamiliesOnDemand()
Get the logical value indicating whether on-demand CF loading should be allowed.
|
boolean |
equals(Object obj) |
byte[] |
getACL()
Gets the acl.
|
boolean |
getAllowPartialResults()
Gets the allow partial results.
|
byte[] |
getAttribute(String name)
Gets the attribute.
|
Map<String,byte[]> |
getAttributesMap()
Gets the attributes map.
|
org.apache.hadoop.hbase.security.visibility.Authorizations |
getAuthorizations()
Gets the authorizations.
|
int |
getBatch()
Gets the batch.
|
boolean |
getCacheBlocks()
Gets the cache blocks.
|
int |
getCaching()
Gets the caching.
|
Map<byte[],org.apache.hadoop.hbase.io.TimeRange> |
getColumnFamilyTimeRange()
Gets the column family time range.
|
org.apache.hadoop.hbase.client.Consistency |
getConsistency()
Returns the consistency level for this operation.
|
byte[][] |
getFamilies()
Gets the families.
|
Map<byte[],NavigableSet<byte[]>> |
getFamilyMap()
Gets the family map.
|
org.apache.hadoop.hbase.filter.Filter |
getFilter()
Gets the filter.
|
Map<String,Object> |
getFingerprint()
Gets the fingerprint.
|
String |
getId()
This method allows you to retrieve the identifier for the operation if one
was set.
|
org.apache.hadoop.hbase.client.IsolationLevel |
getIsolationLevel()
Gets the isolation level.
|
int |
getLimit()
Gets the limit.
|
Boolean |
getLoadColumnFamiliesOnDemandValue()
Get the raw loadColumnFamiliesOnDemand setting; if it's not set, can be null.
|
long |
getMaxResultSize()
Gets the max result size.
|
int |
getMaxResultsPerColumnFamily()
Gets the max results per column family.
|
int |
getMaxVersions()
Gets the max versions.
|
int |
getPriority()
Gets the priority.
|
org.apache.hadoop.hbase.client.Scan.ReadType |
getReadType()
Gets the read type.
|
int |
getReplicaId()
Returns region replica id where Query will fetch data from.
|
int |
getRowOffsetPerColumnFamily()
Gets the row offset per column family.
|
org.apache.hadoop.hbase.client.metrics.ScanMetrics |
getScanMetrics()
Deprecated.
Use
ResultScanner.getScanMetrics() instead. And notice that, please do not
use this method and ResultScanner.getScanMetrics() together, the metrics
will be messed up. |
byte[] |
getStartRow()
Gets the start row.
|
byte[] |
getStopRow()
Gets the stop row.
|
org.apache.hadoop.hbase.io.TimeRange |
getTimeRange()
Gets the time range.
|
boolean |
hasFamilies()
Checks for families.
|
boolean |
hasFilter()
Checks for filter.
|
int |
hashCode() |
boolean |
includeStartRow()
Include start row.
|
boolean |
includeStopRow()
Include stop row.
|
Boolean |
isAsyncPrefetch()
Checks if is async prefetch.
|
boolean |
isGetScan()
Checks if is gets the scan.
|
boolean |
isNeedCursorResult()
Checks if is need cursor result.
|
boolean |
isRaw()
Checks if is raw.
|
boolean |
isReversed()
Checks if is reversed.
|
boolean |
isScanMetricsEnabled()
Checks if is scan metrics enabled.
|
boolean |
isSmall()
Deprecated.
since 2.0.0. See the comment of
setSmall(boolean) |
int |
numFamilies() |
static AnyScan |
of(org.apache.hadoop.hbase.client.Get get) |
static AnyScan |
of(Object startRow)
Deprecated.
use
new Scan().withStartRow(startRow) instead. |
static AnyScan |
of(Object startRow,
org.apache.hadoop.hbase.filter.Filter filter)
Deprecated.
use
new Scan().withStartRow(startRow).setFilter(filter) instead. |
static AnyScan |
of(Object startRow,
Object stopRow)
Deprecated.
use
new Scan().withStartRow(startRow).withStopRow(stopRow) instead. |
static AnyScan |
of(org.apache.hadoop.hbase.client.Scan scan) |
AnyScan |
readAllVersions()
Read all versions.
|
AnyScan |
readVersions(int maxVersions) |
AQ |
setACL(Map<String,org.apache.hadoop.hbase.security.access.Permission> perms)
Sets the ACL.
|
AQ |
setACL(String user,
org.apache.hadoop.hbase.security.access.Permission perms)
Sets the ACL.
|
AnyScan |
setAllowPartialResults(boolean allowPartialResults)
Sets the allow partial results.
|
AnyScan |
setAsyncPrefetch(boolean asyncPrefetch)
Sets the async prefetch.
|
AOWA |
setAttribute(String name,
Object value)
Sets the attribute.
|
AQ |
setAuthorizations(org.apache.hadoop.hbase.security.visibility.Authorizations authorizations)
Sets the authorizations to be used by this Query.
|
AnyScan |
setBatch(int batch)
Sets the batch.
|
AnyScan |
setCacheBlocks(boolean cacheBlocks)
Sets the cache blocks.
|
AnyScan |
setCaching(int caching)
Sets the caching.
|
AnyScan |
setColumnFamilyTimeRange(byte[] family,
long minTimestamp,
long maxTimestamp)
Sets the column family time range.
|
AnyScan |
setColumnFamilyTimeRange(String family,
long minTimestamp,
long maxTimestamp)
Sets the column family time range.
|
AQ |
setConsistency(org.apache.hadoop.hbase.client.Consistency consistency)
Sets the consistency level for this operation.
|
AnyScan |
setFamilyMap(Map<byte[],NavigableSet<byte[]>> familyMap)
Sets the family map.
|
AQ |
setFilter(org.apache.hadoop.hbase.filter.Filter filter)
Apply the specified server-side filter when performing the Query.
|
AOWA |
setId(String id)
This method allows you to set an identifier on an operation.
|
AQ |
setIsolationLevel(org.apache.hadoop.hbase.client.IsolationLevel level)
Set the isolation level for this query.
|
AnyScan |
setLimit(int limit)
Sets the limit.
|
AQ |
setLoadColumnFamiliesOnDemand(boolean value)
Set the value indicating whether loading CFs on demand should be allowed (cluster
default is false).
|
AnyScan |
setMaxResultSize(long maxResultSize)
Sets the max result size.
|
AnyScan |
setMaxResultsPerColumnFamily(int limit)
Sets the max results per column family.
|
AnyScan |
setMaxVersions()
Deprecated.
It is easy to misunderstand with column family's max versions, so use
readAllVersions() instead. |
AnyScan |
setMaxVersions(int maxVersions)
Deprecated.
It is easy to misunderstand with column family's max versions, so use
readAllVersions() instead. |
AnyScan |
setNeedCursorResult(boolean needCursorResult)
Sets the need cursor result.
|
AnyScan |
setOneRowLimit()
Sets the one row limit.
|
AOWA |
setPriority(int priority)
Sets the priority.
|
AnyScan |
setRaw(boolean raw)
Sets the raw.
|
AnyScan |
setReadType(org.apache.hadoop.hbase.client.Scan.ReadType readType)
Set the read type for this scan.
|
AQ |
setReplicaId(int id)
Specify region replica id where Query will fetch data from.
|
AnyScan |
setReversed(boolean reversed)
Sets the reversed.
|
AnyScan |
setRowOffsetPerColumnFamily(int offset)
Sets the row offset per column family.
|
AnyScan |
setRowPrefixFilter(Object rowPrefix)
Sets the row prefix filter.
|
AnyScan |
setScanMetricsEnabled(boolean enabled)
Sets the scan metrics enabled.
|
AnyScan |
setSmall(boolean small)
Deprecated.
since 2.0.0. Use
setLimit(int) and setReadType(ReadType) instead.
And for the one rpc optimization, now we will also fetch data when openScanner, and
if the number of rows reaches the limit then we will close the scanner
automatically which means we will fall back to one rpc. |
AnyScan |
setStartRow(Object startRow)
Deprecated.
use
withStartRow(byte[]) instead. This method may change the inclusive of
the stop row to keep compatible with the old behavior. |
AnyScan |
setStopRow(Object stopRow)
Deprecated.
use
withStopRow(byte[]) instead. This method may change the inclusive of
the stop row to keep compatible with the old behavior. |
AnyScan |
setTimeRange(long minStamp,
long maxStamp)
Sets the time range.
|
AnyScan |
setTimestamp(long timestamp)
Sets the timestamp.
|
AnyScan |
setTimeStamp(long timestamp)
Deprecated.
As of release 2.0.0, this will be removed in HBase 3.0.0.
Use
setTimestamp(long) instead |
String |
toJSON() |
String |
toJSON(int maxCols) |
Map<String,Object> |
toMap() |
Map<String,Object> |
toMap(int maxCols) |
String |
toString() |
String |
toString(int maxCols) |
org.apache.hadoop.hbase.client.Scan |
val() |
AnyScan |
withStartRow(Object startRow)
With start row.
|
AnyScan |
withStartRow(Object startRow,
boolean inclusive)
With start row.
|
AnyScan |
withStopRow(Object stopRow)
With stop row.
|
AnyScan |
withStopRow(Object stopRow,
boolean inclusive)
With stop row.
|
public static AnyScan create()
public static AnyScan createScanFromCursor(org.apache.hadoop.hbase.client.Cursor cursor)
cursor
- @Deprecated public static AnyScan of(Object startRow)
new Scan().withStartRow(startRow)
instead.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 after@Deprecated public static AnyScan of(Object startRow, Object stopRow)
new Scan().withStartRow(startRow).withStopRow(stopRow)
instead.startRow
- row to start scanner at or after (inclusive)stopRow
- row to stop scanner before (exclusive)@Deprecated public static AnyScan of(Object startRow, org.apache.hadoop.hbase.filter.Filter filter)
new Scan().withStartRow(startRow).setFilter(filter)
instead.startRow
- filter
- public static AnyScan of(org.apache.hadoop.hbase.client.Scan scan)
scan
- public static AnyScan of(org.apache.hadoop.hbase.client.Get get)
get
- public org.apache.hadoop.hbase.client.Scan val()
public boolean isGetScan()
public boolean hasFamilies()
public int numFamilies()
public byte[][] getFamilies()
public AnyScan addFamily(byte[] family)
family
- public Map<byte[],NavigableSet<byte[]>> getFamilyMap()
public AnyScan setFamilyMap(Map<byte[],NavigableSet<byte[]>> familyMap)
familyMap
- public AnyScan setColumnFamilyTimeRange(String family, long minTimestamp, long maxTimestamp)
family
- minTimestamp
- maxTimestamp
- public AnyScan setColumnFamilyTimeRange(byte[] family, long minTimestamp, long maxTimestamp)
family
- minTimestamp
- maxTimestamp
- public AnyScan addColumn(String family, String qualifier)
family
- qualifier
- public AnyScan addColumn(byte[] family, byte[] qualifier)
family
- qualifier
- public org.apache.hadoop.hbase.io.TimeRange getTimeRange()
public AnyScan setTimeRange(long minStamp, long maxStamp)
minStamp
- maxStamp
- public AnyScan setTimestamp(long timestamp)
timestamp
- @Deprecated public AnyScan setTimeStamp(long timestamp)
setTimestamp(long)
insteadtimestamp
- version timestampScan.setMaxVersions()
,
Scan.setMaxVersions(int)
public boolean includeStartRow()
public byte[] getStartRow()
@Deprecated public AnyScan setStartRow(Object startRow)
withStartRow(byte[])
instead. This method may change the inclusive of
the stop row to keep compatible with the old behavior.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 afterIllegalArgumentException
- if startRow does not meet criteria for a row key (when length
exceeds HConstants.MAX_ROW_LENGTH
)public AnyScan withStartRow(Object startRow)
startRow
- public AnyScan withStartRow(Object startRow, boolean inclusive)
startRow
- inclusive
- public boolean includeStopRow()
public byte[] getStopRow()
@Deprecated public AnyScan setStopRow(Object stopRow)
withStopRow(byte[])
instead. This method may change the inclusive of
the stop row to keep compatible with the old behavior.The scan will include rows that are lexicographically less than the provided stopRow.
Note: When doing a filter for a rowKey Prefix use
setRowPrefixFilter(byte[])
. The 'trailing 0' will not yield the desired result.
stopRow
- row to end at (exclusive)IllegalArgumentException
- if stopRow does not meet criteria for a row key (when length
exceeds HConstants.MAX_ROW_LENGTH
)public AnyScan withStopRow(Object stopRow)
stopRow
- public AnyScan withStopRow(Object stopRow, boolean inclusive)
stopRow
- inclusive
- public AnyScan setRowPrefixFilter(Object rowPrefix)
rowPrefix
- public int getMaxVersions()
@Deprecated public AnyScan setMaxVersions(int maxVersions)
readAllVersions()
instead.maxVersions
- @Deprecated public AnyScan setMaxVersions()
readAllVersions()
instead.public AnyScan readVersions(int maxVersions)
maxVersions
- public AnyScan readAllVersions()
public int getBatch()
public AnyScan setBatch(int batch)
batch
- public int getMaxResultsPerColumnFamily()
public AnyScan setMaxResultsPerColumnFamily(int limit)
limit
- public int getRowOffsetPerColumnFamily()
public AnyScan setRowOffsetPerColumnFamily(int offset)
offset
- public int getCaching()
public AnyScan setCaching(int caching)
caching
- public boolean getCacheBlocks()
public AnyScan setCacheBlocks(boolean cacheBlocks)
cacheBlocks
- public long getMaxResultSize()
public AnyScan setMaxResultSize(long maxResultSize)
maxResultSize
- public int getLimit()
public AnyScan setLimit(int limit)
limit
- public AnyScan setOneRowLimit()
public boolean hasFilter()
public boolean isReversed()
public AnyScan setReversed(boolean reversed)
reversed
- public boolean getAllowPartialResults()
public AnyScan setAllowPartialResults(boolean allowPartialResults)
allowPartialResults
- public boolean isRaw()
public AnyScan setRaw(boolean raw)
raw
- @Deprecated public boolean isSmall()
setSmall(boolean)
@Deprecated public AnyScan setSmall(boolean small)
setLimit(int)
and setReadType(ReadType)
instead.
And for the one rpc optimization, now we will also fetch data when openScanner, and
if the number of rows reaches the limit then we will close the scanner
automatically which means we will fall back to one rpc.Small scan should use pread and big scan can use seek + read seek + read is fast but can cause two problem (1) resource contention (2) cause too much network io [89-fb] Using pread for non-compaction read request https://issues.apache.org/jira/browse/HBASE-7266 On the other hand, if setting it true, we would do openScanner,next,closeScanner in one RPC call. It means the better performance for small scan. [HBASE-9488]. Generally, if the scan range is within one data block(64KB), it could be considered as a small scan.
small
- Scan.setLimit(int)
,
Scan.setReadType(ReadType)
public boolean isScanMetricsEnabled()
public AnyScan setScanMetricsEnabled(boolean enabled)
enabled
- @Deprecated public org.apache.hadoop.hbase.client.metrics.ScanMetrics getScanMetrics()
ResultScanner.getScanMetrics()
instead. And notice that, please do not
use this method and ResultScanner.getScanMetrics()
together, the metrics
will be messed up.Scan.setScanMetricsEnabled(boolean)
public Boolean isAsyncPrefetch()
public AnyScan setAsyncPrefetch(boolean asyncPrefetch)
asyncPrefetch
- public org.apache.hadoop.hbase.client.Scan.ReadType getReadType()
public AnyScan setReadType(org.apache.hadoop.hbase.client.Scan.ReadType readType)
Notice that we may choose to use pread even if you specific Scan.ReadType.STREAM
here. For
example, we will always use pread if this is a get scan.
readType
- public boolean isNeedCursorResult()
public AnyScan setNeedCursorResult(boolean needCursorResult)
needCursorResult
- public boolean equals(Object obj)
public String toString()
public org.apache.hadoop.hbase.filter.Filter getFilter()
public AQ setFilter(org.apache.hadoop.hbase.filter.Filter filter)
Filter.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.filter
- filter to run on the serverpublic org.apache.hadoop.hbase.security.visibility.Authorizations getAuthorizations() throws org.apache.hadoop.hbase.exceptions.DeserializationException
org.apache.hadoop.hbase.exceptions.DeserializationException
- the deserialization exceptionpublic AQ setAuthorizations(org.apache.hadoop.hbase.security.visibility.Authorizations authorizations)
authorizations
- public byte[] getACL()
public AQ setACL(String user, org.apache.hadoop.hbase.security.access.Permission perms)
user
- User short nameperms
- Permissions for the userpublic AQ setACL(Map<String,org.apache.hadoop.hbase.security.access.Permission> perms)
perms
- A map of permissions for a user or userspublic org.apache.hadoop.hbase.client.Consistency getConsistency()
public AQ setConsistency(org.apache.hadoop.hbase.client.Consistency consistency)
consistency
- the consistency levelpublic int getReplicaId()
public AQ setReplicaId(int id)
setConsistency(Consistency)
passing Consistency.TIMELINE
to read data from
a specific replicaId.
id
- public org.apache.hadoop.hbase.client.IsolationLevel getIsolationLevel()
public AQ setIsolationLevel(org.apache.hadoop.hbase.client.IsolationLevel level)
level
- IsolationLevel for this querypublic Boolean getLoadColumnFamiliesOnDemandValue()
public AQ setLoadColumnFamiliesOnDemand(boolean value)
value
- public boolean doLoadColumnFamiliesOnDemand()
public Map<byte[],org.apache.hadoop.hbase.io.TimeRange> getColumnFamilyTimeRange()
public byte[] getAttribute(String name)
name
- public AOWA setAttribute(String name, Object value)
name
- value
- public String getId()
public AOWA setId(String id)
id
- id to set for the scanpublic int getPriority()
public AOWA setPriority(int priority)
priority
- public String toJSON()
public String toJSON(int maxCols)
maxCols
- public String toString(int maxCols)
maxCols
- Copyright © 2021. All rights reserved.