@InterfaceAudience.Private public final class ImmutableScan extends Scan
Scan.ReadType
DEFAULT_HBASE_CLIENT_SCANNER_ASYNC_PREFETCH, HBASE_CLIENT_SCANNER_ASYNC_PREFETCH, SCAN_ATTRIBUTES_METRICS_DATA, SCAN_ATTRIBUTES_METRICS_ENABLE, SCAN_ATTRIBUTES_TABLE_NAME
colFamTimeRangeMap, consistency, filter, loadColumnFamiliesOnDemand, targetReplicaId
ID_ATRIBUTE
Constructor and Description |
---|
ImmutableScan(Scan scan)
Create Immutable instance of Scan from given Scan object
|
Modifier and Type | Method and Description |
---|---|
Scan |
addColumn(byte[] family,
byte[] qualifier)
Get the column from the specified family with the specified qualifier.
|
Scan |
addFamily(byte[] family)
Get all columns from the specified family.
|
boolean |
doLoadColumnFamiliesOnDemand()
Get the logical value indicating whether on-demand CF loading should be allowed.
|
byte[] |
getACL() |
boolean |
getAllowPartialResults() |
byte[] |
getAttribute(String name)
Gets an attribute
|
long |
getAttributeSize() |
Map<String,byte[]> |
getAttributesMap()
Gets all attributes
|
Authorizations |
getAuthorizations() |
int |
getBatch() |
boolean |
getCacheBlocks()
Get whether blocks should be cached for this Scan.
|
int |
getCaching() |
Map<byte[],TimeRange> |
getColumnFamilyTimeRange() |
Consistency |
getConsistency()
Returns the consistency level for this operation
|
byte[][] |
getFamilies() |
Map<byte[],NavigableSet<byte[]>> |
getFamilyMap()
Getting the familyMap
|
Filter |
getFilter() |
Map<String,Object> |
getFingerprint()
Compile the table and column family (i.e.
|
String |
getId()
This method allows you to retrieve the identifier for the operation if one
was set.
|
IsolationLevel |
getIsolationLevel() |
int |
getLimit() |
Boolean |
getLoadColumnFamiliesOnDemandValue()
Get the raw loadColumnFamiliesOnDemand setting; if it's not set, can be null.
|
long |
getMaxResultSize() |
int |
getMaxResultsPerColumnFamily() |
int |
getMaxVersions() |
int |
getPriority() |
Scan.ReadType |
getReadType() |
int |
getReplicaId()
Returns region replica id where Query will fetch data from.
|
int |
getRowOffsetPerColumnFamily()
Method for retrieving the scan's offset per row per column
family (#kvs to be skipped)
|
byte[] |
getStartRow() |
byte[] |
getStopRow() |
TimeRange |
getTimeRange() |
boolean |
hasFamilies() |
boolean |
hasFilter() |
boolean |
includeStartRow() |
boolean |
includeStopRow() |
Boolean |
isAsyncPrefetch() |
boolean |
isGetScan() |
boolean |
isNeedCursorResult() |
boolean |
isRaw() |
boolean |
isReversed()
Get whether this scan is a reversed one.
|
boolean |
isScanMetricsEnabled() |
boolean |
isSmall()
Deprecated.
|
int |
numFamilies() |
Scan |
readAllVersions()
Get all available versions.
|
Scan |
readVersions(int versions)
Get up to the specified number of versions of each column.
|
Scan |
setACL(Map<String,Permission> perms) |
Scan |
setACL(String user,
Permission perms) |
Scan |
setAllowPartialResults(boolean allowPartialResults)
Setting whether the caller wants to see the partial results when server returns
less-than-expected cells.
|
Scan |
setAsyncPrefetch(boolean asyncPrefetch)
Deprecated.
|
Scan |
setAttribute(String name,
byte[] value)
Sets an attribute.
|
Scan |
setAuthorizations(Authorizations authorizations)
Sets the authorizations to be used by this Query
|
Scan |
setBatch(int batch)
Set the maximum number of cells to return for each call to next().
|
Scan |
setCacheBlocks(boolean cacheBlocks)
Set whether blocks should be cached for this Scan.
|
Scan |
setCaching(int caching)
Set the number of rows for caching that will be passed to scanners.
|
Scan |
setColumnFamilyTimeRange(byte[] cf,
long minStamp,
long maxStamp)
Get versions of columns only within the specified timestamp range,
[minStamp, maxStamp) on a per CF bases.
|
Scan |
setConsistency(Consistency consistency)
Sets the consistency level for this operation
|
Scan |
setFamilyMap(Map<byte[],NavigableSet<byte[]>> familyMap)
Setting the familyMap
|
Scan |
setFilter(Filter filter)
Apply the specified server-side filter when performing the Query.
|
Scan |
setId(String id)
This method allows you to set an identifier on an operation.
|
Scan |
setIsolationLevel(IsolationLevel level)
Set the isolation level for this query.
|
Scan |
setLimit(int limit)
Set the limit of rows for this scan.
|
Scan |
setLoadColumnFamiliesOnDemand(boolean value)
Set the value indicating whether loading CFs on demand should be allowed (cluster
default is false).
|
Scan |
setMaxResultSize(long maxResultSize)
Set the maximum result size.
|
Scan |
setMaxResultsPerColumnFamily(int limit)
Set the maximum number of values to return per row per Column Family
|
Scan |
setNeedCursorResult(boolean needCursorResult)
When the server is slow or we scan a table with many deleted data or we use a sparse filter,
the server will response heartbeat to prevent timeout.
|
Scan |
setOneRowLimit()
Call this when you only want to get one row.
|
Scan |
setPriority(int priority) |
Scan |
setRaw(boolean raw)
Enable/disable "raw" mode for this scan.
|
Scan |
setReadType(Scan.ReadType readType)
Set the read type for this scan.
|
Scan |
setReplicaId(int id)
Specify region replica id where Query will fetch data from.
|
Scan |
setReversed(boolean reversed)
Set whether this scan is a reversed one
|
Scan |
setRowOffsetPerColumnFamily(int offset)
Set offset for the row per Column Family.
|
Scan |
setRowPrefixFilter(byte[] rowPrefix)
Set a filter (using stopRow and startRow) so the result set only contains rows where the
rowKey starts with the specified prefix.
|
Scan |
setScanMetricsEnabled(boolean enabled)
Enable collection of
ScanMetrics . |
Scan |
setSmall(boolean small)
Deprecated.
|
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.
|
Scan |
setTimeStamp(long timestamp)
Deprecated.
|
String |
toJSON()
Produces a JSON object sufficient for description of a query
in a debugging or logging context.
|
String |
toJSON(int maxCols)
Produces a JSON object for fingerprint and details exposure in a
parseable format.
|
Map<String,Object> |
toMap()
Produces a Map containing a full summary of a query.
|
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.
|
String |
toString()
Produces a string representation of this Operation.
|
String |
toString(int maxCols)
Produces a string representation of this Operation.
|
Scan |
withStartRow(byte[] startRow)
Set the start row of the scan.
|
Scan |
withStartRow(byte[] startRow,
boolean inclusive)
Set the start row of the scan.
|
Scan |
withStopRow(byte[] stopRow)
Set the stop row of the scan.
|
Scan |
withStopRow(byte[] stopRow,
boolean inclusive)
Set the stop row of the scan.
|
createScanFromCursor, getScanMetrics, setMaxVersions, setMaxVersions, setStartRow, setStopRow
public ImmutableScan(Scan scan)
scan
- Copy all values from Scanpublic Scan addFamily(byte[] family)
Scan
Overrides previous calls to addColumn for this family.
public Scan addColumn(byte[] family, byte[] qualifier)
Scan
Overrides previous calls to addFamily for this family.
public Scan setTimeRange(long minStamp, long maxStamp)
Scan
setTimeRange
in class Scan
minStamp
- minimum timestamp value, inclusivemaxStamp
- maximum timestamp value, exclusiveScan.setMaxVersions()
,
Scan.setMaxVersions(int)
@Deprecated public Scan setTimeStamp(long timestamp)
Scan
setTimeStamp
in class Scan
timestamp
- version timestampScan.setMaxVersions()
,
Scan.setMaxVersions(int)
public Scan setTimestamp(long timestamp)
Scan
setTimestamp
in class Scan
timestamp
- version timestampScan.setMaxVersions()
,
Scan.setMaxVersions(int)
public Scan setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp)
Query
setColumnFamilyTimeRange
in class Scan
cf
- the column family for which you want to restrictminStamp
- minimum timestamp value, inclusivemaxStamp
- maximum timestamp value, exclusivepublic Scan withStartRow(byte[] startRow)
Scan
If the specified row does not exist, the Scanner will start from the next closest row after the specified row.
withStartRow
in class Scan
startRow
- row to start scanner at or afterpublic Scan withStartRow(byte[] startRow, boolean inclusive)
Scan
If the specified row does not exist, or the inclusive
is false
, the Scanner
will start from the next closest row after the specified row.
withStartRow
in class Scan
startRow
- row to start scanner at or afterinclusive
- whether we should include the start row when scanpublic Scan withStopRow(byte[] stopRow)
Scan
The scan will include rows that are lexicographically less than the provided stopRow.
Note: When doing a filter for a rowKey Prefix use
Scan.setRowPrefixFilter(byte[])
. The 'trailing 0' will not yield the desired result.
withStopRow
in class Scan
stopRow
- row to end at (exclusive)public Scan withStopRow(byte[] stopRow, boolean inclusive)
Scan
The scan will include rows that are lexicographically less than (or equal to if
inclusive
is true
) the provided stopRow.
withStopRow
in class Scan
stopRow
- row to end atinclusive
- whether we should include the stop row when scanpublic Scan setRowPrefixFilter(byte[] rowPrefix)
Scan
Set a filter (using stopRow and startRow) so the result set only contains rows where the rowKey starts with the specified prefix.
This is a utility method that converts the desired rowPrefix into the appropriate values for the startRow and stopRow to achieve the desired result.
This can safely be used in combination with setFilter.
NOTE: Doing a Scan.setStartRow(byte[])
and/or Scan.setStopRow(byte[])
after this method will yield undefined results.
setRowPrefixFilter
in class Scan
rowPrefix
- the prefix all rows must start with. (Set null to remove the filter.)public Scan readAllVersions()
Scan
readAllVersions
in class Scan
public Scan readVersions(int versions)
Scan
readVersions
in class Scan
versions
- specified number of versions for each columnpublic Scan setBatch(int batch)
Scan
Scan.setAllowPartialResults(boolean)
.
If you don't allow partial results, the number of cells in each Result must equal to your
batch setting unless it is the last Result for current row. So this method is helpful in paging
queries. If you just want to prevent OOM at client, use setAllowPartialResults(true) is better.setBatch
in class Scan
batch
- the maximum number of valuesResult.mayHaveMoreCellsInRow()
public Scan setMaxResultsPerColumnFamily(int limit)
Scan
setMaxResultsPerColumnFamily
in class Scan
limit
- the maximum number of values returned / row / CFpublic Scan setRowOffsetPerColumnFamily(int offset)
Scan
setRowOffsetPerColumnFamily
in class Scan
offset
- is the number of kvs that will be skipped.public Scan setCaching(int caching)
Scan
HConstants.HBASE_CLIENT_SCANNER_CACHING
will
apply.
Higher caching values will enable faster scanners but will use more memory.setCaching
in class Scan
caching
- the number of rows for cachingpublic Scan setMaxResultSize(long maxResultSize)
Scan
setMaxResultSize
in class Scan
maxResultSize
- The maximum result size in bytes.public Scan setFilter(Filter filter)
Query
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.public Scan setFamilyMap(Map<byte[],NavigableSet<byte[]>> familyMap)
Scan
setFamilyMap
in class Scan
familyMap
- map of family to qualifierpublic Scan setCacheBlocks(boolean cacheBlocks)
Scan
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).
setCacheBlocks
in class Scan
cacheBlocks
- if false, default settings are overridden and blocks
will not be cachedpublic Scan setReversed(boolean reversed)
Scan
This is false by default which means forward(normal) scan.
setReversed
in class Scan
reversed
- if true, scan will be backward orderpublic Scan setAllowPartialResults(boolean allowPartialResults)
Scan
setAllowPartialResults
in class Scan
Result.mayHaveMoreCellsInRow()
,
Scan.setBatch(int)
public Scan setLoadColumnFamiliesOnDemand(boolean value)
Query
setLoadColumnFamiliesOnDemand
in class Scan
public Scan setRaw(boolean raw)
Scan
@Deprecated public Scan setSmall(boolean small)
Scan
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.
setSmall
in class Scan
Scan.setLimit(int)
,
Scan.setReadType(ReadType)
,
HBASE-17045public Scan setAttribute(String name, byte[] value)
Attributes
setAttribute
in interface Attributes
setAttribute
in class Scan
name
- attribute namevalue
- attribute valuepublic Scan setId(String id)
OperationWithAttributes
public Scan setAuthorizations(Authorizations authorizations)
Query
setAuthorizations
in class Scan
public Scan setACL(Map<String,Permission> perms)
public Scan setACL(String user, Permission perms)
public Scan setConsistency(Consistency consistency)
Query
setConsistency
in class Scan
consistency
- the consistency levelpublic Scan setReplicaId(int id)
Query
Query.setConsistency(Consistency)
passing Consistency.TIMELINE
to read data from
a specific replicaId.
setReplicaId
in class Scan
public Scan setIsolationLevel(IsolationLevel level)
Query
setIsolationLevel
in class Scan
level
- IsolationLevel for this querypublic Scan setPriority(int priority)
setPriority
in class Scan
public Scan setScanMetricsEnabled(boolean enabled)
Scan
ScanMetrics
. For advanced users.setScanMetricsEnabled
in class Scan
enabled
- Set to true to enable accumulating scan metrics@Deprecated public Scan setAsyncPrefetch(boolean asyncPrefetch)
setAsyncPrefetch
in class Scan
public Scan setLimit(int limit)
Scan
This condition will be tested at last, after all other conditions such as stopRow, filter, etc.
public Scan setOneRowLimit()
Scan
limit
to 1
, and also
set readType
to Scan.ReadType.PREAD
.setOneRowLimit
in class Scan
public Scan setReadType(Scan.ReadType readType)
Scan
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.
setReadType
in class Scan
public Scan setNeedCursorResult(boolean needCursorResult)
Scan
Result.isCursor()
Result.getCursor()
Cursor
setNeedCursorResult
in class Scan
public long getMaxResultSize()
getMaxResultSize
in class Scan
Scan.setMaxResultSize(long)
public Map<byte[],NavigableSet<byte[]>> getFamilyMap()
Scan
getFamilyMap
in class Scan
public int numFamilies()
numFamilies
in class Scan
public boolean hasFamilies()
hasFamilies
in class Scan
public byte[][] getFamilies()
getFamilies
in class Scan
public byte[] getStartRow()
getStartRow
in class Scan
public boolean includeStartRow()
includeStartRow
in class Scan
public byte[] getStopRow()
getStopRow
in class Scan
public boolean includeStopRow()
includeStopRow
in class Scan
public int getMaxVersions()
getMaxVersions
in class Scan
public int getBatch()
public int getMaxResultsPerColumnFamily()
getMaxResultsPerColumnFamily
in class Scan
public int getRowOffsetPerColumnFamily()
Scan
getRowOffsetPerColumnFamily
in class Scan
public int getCaching()
getCaching
in class Scan
public TimeRange getTimeRange()
getTimeRange
in class Scan
public boolean hasFilter()
public boolean getCacheBlocks()
Scan
getCacheBlocks
in class Scan
public boolean isReversed()
Scan
isReversed
in class Scan
public boolean getAllowPartialResults()
getAllowPartialResults
in class Scan
ResultScanner.next()
public byte[] getACL()
public Map<String,Object> getFingerprint()
Scan
getFingerprint
in class Scan
public Map<String,Object> toMap(int maxCols)
Scan
public boolean isRaw()
@Deprecated public boolean isSmall()
Scan
isSmall
in class Scan
public boolean isScanMetricsEnabled()
isScanMetricsEnabled
in class Scan
public Boolean isAsyncPrefetch()
isAsyncPrefetch
in class Scan
public int getLimit()
public Scan.ReadType getReadType()
getReadType
in class Scan
public boolean isNeedCursorResult()
isNeedCursorResult
in class Scan
public byte[] getAttribute(String name)
Attributes
getAttribute
in interface Attributes
getAttribute
in class OperationWithAttributes
name
- attribute namepublic Consistency getConsistency()
Query
getConsistency
in class Query
public long getAttributeSize()
getAttributeSize
in class OperationWithAttributes
public Map<String,byte[]> getAttributesMap()
Attributes
getAttributesMap
in interface Attributes
getAttributesMap
in class OperationWithAttributes
public Boolean getLoadColumnFamiliesOnDemandValue()
Query
getLoadColumnFamiliesOnDemandValue
in class Query
public int getPriority()
getPriority
in class OperationWithAttributes
public Map<byte[],TimeRange> getColumnFamilyTimeRange()
getColumnFamilyTimeRange
in class Query
public int getReplicaId()
Query
getReplicaId
in class Query
public boolean doLoadColumnFamiliesOnDemand()
Query
doLoadColumnFamiliesOnDemand
in class Query
public String getId()
OperationWithAttributes
getId
in class OperationWithAttributes
public IsolationLevel getIsolationLevel()
getIsolationLevel
in class Query
public Authorizations getAuthorizations() throws DeserializationException
getAuthorizations
in class Query
DeserializationException
public String toString(int maxCols)
Operation
public String toString()
Operation
public Map<String,Object> toMap()
Operation
public String toJSON(int maxCols) throws IOException
Operation
toJSON
in class Operation
maxCols
- a limit on the number of columns to include in the JSONIOException
public String toJSON() throws IOException
Operation
toJSON
in class Operation
IOException
Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.