@InterfaceAudience.Private public final class ImmutableScan extends Scan
Scan.ReadTypeDEFAULT_HBASE_CLIENT_SCANNER_ASYNC_PREFETCH, HBASE_CLIENT_SCANNER_ASYNC_PREFETCH, SCAN_ATTRIBUTES_METRICS_DATA, SCAN_ATTRIBUTES_METRICS_ENABLE, SCAN_ATTRIBUTES_TABLE_NAMEcolFamTimeRangeMap, consistency, filter, loadColumnFamiliesOnDemand, targetReplicaIdID_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()
Returns The serialized ACL for this operation, or null if none
|
boolean |
getAllowPartialResults()
Returns true when the constructor of this scan understands that the results they will see may
only represent a partial portion of a row.
|
byte[] |
getAttribute(String name)
Gets an attribute
|
long |
getAttributeSize() |
Map<String,byte[]> |
getAttributesMap()
Gets all attributes
|
Authorizations |
getAuthorizations()
Returns The authorizations this Query is associated with.
|
int |
getBatch()
Returns maximum number of values to return for a single call to next()
|
boolean |
getCacheBlocks()
Get whether blocks should be cached for this Scan.
|
int |
getCaching()
Returns caching the number of rows fetched when calling next on a scanner
|
Map<byte[],TimeRange> |
getColumnFamilyTimeRange()
Returns A map of column families to time ranges
|
Consistency |
getConsistency()
Returns the consistency level for this operation
|
byte[][] |
getFamilies()
Returns the keys of the familyMap
|
Map<byte[],NavigableSet<byte[]>> |
getFamilyMap()
Getting the familyMap n
|
Filter |
getFilter()
n
|
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()
Returns The isolation level of this query.
|
int |
getLimit()
Returns the limit of rows for this scan
|
Boolean |
getLoadColumnFamiliesOnDemandValue()
Get the raw loadColumnFamiliesOnDemand setting; if it's not set, can be null.
|
long |
getMaxResultSize()
Returns the maximum result size in bytes.
|
int |
getMaxResultsPerColumnFamily()
Returns maximum number of values to return per row per CF
|
int |
getMaxVersions()
Returns the max number of versions to fetch
|
int |
getPriority() |
Scan.ReadType |
getReadType()
Returns the read type for this scan
|
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()
Returns the startrow
|
byte[] |
getStopRow()
Returns the stoprow
|
TimeRange |
getTimeRange()
n
|
boolean |
hasFamilies()
Returns true if familyMap is non empty, false otherwise
|
boolean |
hasFilter()
Returns true is a filter has been specified, false if not
|
boolean |
includeStartRow()
Returns if we should include start row when scan
|
boolean |
includeStopRow()
Returns if we should include stop row when scan
|
Boolean |
isAsyncPrefetch() |
boolean |
isGetScan() |
boolean |
isNeedCursorResult() |
boolean |
isRaw()
Returns True if this Scan is in "raw" mode.
|
boolean |
isReversed()
Get whether this scan is a reversed one.
|
boolean |
isScanMetricsEnabled()
Returns True if collection of scan metrics is enabled.
|
boolean |
isSmall()
Deprecated.
|
int |
numFamilies()
Returns the number of families in familyMap
|
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)
Set the ACL for the operation.
|
Scan |
setACL(String user,
Permission perms)
Set the ACL for the operation.
|
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 n
|
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 |
setScanMetricsEnabled(boolean enabled)
Enable collection of
ScanMetrics. |
Scan |
setSmall(boolean small)
Deprecated.
|
Scan |
setStartStopRowForPrefixScan(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 |
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, setRowPrefixFilter, setStartRow, setStopRowpublic ImmutableScan(Scan scan)
scan - Copy all values from Scanpublic Scan addFamily(byte[] family)
ScanOverrides previous calls to addColumn for this family.
public Scan addColumn(byte[] family, byte[] qualifier)
ScanOverrides previous calls to addFamily for this family.
public Scan setTimeRange(long minStamp, long maxStamp)
ScansetTimeRange in class ScanminStamp - minimum timestamp value, inclusivemaxStamp - maximum timestamp value, exclusiveScan.setMaxVersions(),
n@Deprecated public Scan setTimeStamp(long timestamp)
ScansetTimeStamp in class Scantimestamp - version timestampScan.setMaxVersions(),
n * @deprecated As of release 2.0.0, this will be removed in HBase
3.0.0. Use {@link #setTimestamp(long)} insteadpublic Scan setTimestamp(long timestamp)
ScansetTimestamp in class Scantimestamp - version timestampScan.setMaxVersions(),
npublic Scan setColumnFamilyTimeRange(byte[] cf, long minStamp, long maxStamp)
QuerysetColumnFamilyTimeRange in class Scancf - the column family for which you want to restrictminStamp - minimum timestamp value, inclusivemaxStamp - maximum timestamp value, exclusive npublic Scan withStartRow(byte[] startRow)
ScanIf the specified row does not exist, the Scanner will start from the next closest row after the specified row.
withStartRow in class ScanstartRow - row to start scanner at or after n * @throws IllegalArgumentException if
startRow does not meet criteria for a row key (when length exceeds
HConstants.MAX_ROW_LENGTH)public 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.
Note: Do NOT use this in combination with Scan.setRowPrefixFilter(byte[]) or
Scan.setStartStopRowForPrefixScan(byte[]). Doing so will make the scan result
unexpected or even undefined.
withStartRow in class ScanstartRow - row to start scanner at or afterinclusive - whether we should include the start row when scan n * @throws
IllegalArgumentException if startRow does not meet criteria for a row key
(when length exceeds HConstants.MAX_ROW_LENGTH)public Scan withStopRow(byte[] stopRow)
ScanThe 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 ScanstopRow - row to end at (exclusive) n * @throws IllegalArgumentException if stopRow does
not meet criteria for a row key (when length exceeds
HConstants.MAX_ROW_LENGTH)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.
Note: Do NOT use this in combination with Scan.setRowPrefixFilter(byte[]) or
Scan.setStartStopRowForPrefixScan(byte[]). Doing so will make the scan result
unexpected or even undefined.
withStopRow in class ScanstopRow - row to end atinclusive - whether we should include the stop row when scan n * @throws
IllegalArgumentException if stopRow does not meet criteria for a row key (when
length exceeds HConstants.MAX_ROW_LENGTH)public Scan setStartStopRowForPrefixScan(byte[] rowPrefix)
ScanSet 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.
This CANNOT be used in combination with withStartRow and/or withStopRow. Such a combination will yield unexpected and even undefined results.
setStartStopRowForPrefixScan in class ScanrowPrefix - the prefix all rows must start with. (Set null to remove the filter.) npublic Scan readAllVersions()
ScanreadAllVersions in class Scanpublic Scan readVersions(int versions)
ScanreadVersions in class Scanversions - specified number of versions for each column npublic Scan setBatch(int batch)
ScanScan.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 Scanbatch - the maximum number of valuesResult.mayHaveMoreCellsInRow()public Scan setMaxResultsPerColumnFamily(int limit)
ScansetMaxResultsPerColumnFamily in class Scanlimit - the maximum number of values returned / row / CFpublic Scan setRowOffsetPerColumnFamily(int offset)
ScansetRowOffsetPerColumnFamily in class Scanoffset - is the number of kvs that will be skipped.public Scan setCaching(int caching)
ScanHConstants.HBASE_CLIENT_SCANNER_CACHING will apply. Higher
caching values will enable faster scanners but will use more memory.setCaching in class Scancaching - the number of rows for cachingpublic Scan setMaxResultSize(long maxResultSize)
ScansetMaxResultSize in class ScanmaxResultSize - The maximum result size in bytes.public Scan setFilter(Filter filter)
QueryFilter.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)
ScansetFamilyMap in class ScanfamilyMap - map of family to qualifier npublic Scan setCacheBlocks(boolean cacheBlocks)
ScanThis 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 ScancacheBlocks - if false, default settings are overridden and blocks will not be cachedpublic Scan setReversed(boolean reversed)
ScanThis is false by default which means forward(normal) scan.
setReversed in class Scanreversed - if true, scan will be backward order npublic Scan setAllowPartialResults(boolean allowPartialResults)
ScansetAllowPartialResults in class ScanScan.setBatch(int)public Scan setLoadColumnFamiliesOnDemand(boolean value)
QuerysetLoadColumnFamiliesOnDemand in class Scanpublic Scan setRaw(boolean raw)
Scan@Deprecated public Scan setSmall(boolean small)
ScanSmall 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 Scansmall - set if that should use read type of PREADScan.setLimit(int),
Scan.setReadType(ReadType),
HBASE-17045public Scan setAttribute(String name, byte[] value)
AttributessetAttribute in interface AttributessetAttribute in class Scanname - attribute namevalue - attribute valuepublic Scan setId(String id)
OperationWithAttributespublic Scan setAuthorizations(Authorizations authorizations)
QuerysetAuthorizations in class Scanpublic Scan setACL(Map<String,Permission> perms)
Querypublic Scan setACL(String user, Permission perms)
Querypublic Scan setConsistency(Consistency consistency)
QuerysetConsistency in class Scanconsistency - the consistency levelpublic Scan setReplicaId(int id)
QueryQuery.setConsistency(Consistency) passing Consistency.TIMELINE to read data from a
specific replicaId. setReplicaId in class Scanpublic Scan setIsolationLevel(IsolationLevel level)
QuerysetIsolationLevel in class Scanlevel - IsolationLevel for this querypublic Scan setPriority(int priority)
setPriority in class Scanpublic Scan setScanMetricsEnabled(boolean enabled)
ScanScanMetrics. For advanced users.setScanMetricsEnabled in class Scanenabled - Set to true to enable accumulating scan metrics@Deprecated public Scan setAsyncPrefetch(boolean asyncPrefetch)
setAsyncPrefetch in class Scanpublic Scan setLimit(int limit)
ScanThis condition will be tested at last, after all other conditions such as stopRow, filter, etc.
public Scan setOneRowLimit()
Scanlimit to 1, and also
set readType to Scan.ReadType.PREAD. nsetOneRowLimit in class Scanpublic 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. n
setReadType in class Scanpublic Scan setNeedCursorResult(boolean needCursorResult)
ScanResult.isCursor() Result.getCursor() CursorsetNeedCursorResult in class Scanpublic long getMaxResultSize()
ScanScan.setMaxResultSize(long)getMaxResultSize in class Scanpublic Map<byte[],NavigableSet<byte[]>> getFamilyMap()
ScangetFamilyMap in class Scanpublic int numFamilies()
ScannumFamilies in class Scanpublic boolean hasFamilies()
ScanhasFamilies in class Scanpublic byte[][] getFamilies()
ScangetFamilies in class Scanpublic byte[] getStartRow()
ScangetStartRow in class Scanpublic boolean includeStartRow()
ScanincludeStartRow in class Scanpublic byte[] getStopRow()
ScangetStopRow in class Scanpublic boolean includeStopRow()
ScanincludeStopRow in class Scanpublic int getMaxVersions()
ScangetMaxVersions in class Scanpublic int getBatch()
Scanpublic int getMaxResultsPerColumnFamily()
ScangetMaxResultsPerColumnFamily in class Scanpublic int getRowOffsetPerColumnFamily()
ScangetRowOffsetPerColumnFamily in class Scanpublic int getCaching()
ScangetCaching in class Scanpublic TimeRange getTimeRange()
ScangetTimeRange in class Scanpublic boolean hasFilter()
Scanpublic boolean getCacheBlocks()
ScangetCacheBlocks in class Scanpublic boolean isReversed()
ScanisReversed in class Scanpublic boolean getAllowPartialResults()
ScanResultScanner.next()getAllowPartialResults in class Scanpublic byte[] getACL()
Querypublic Map<String,Object> getFingerprint()
ScangetFingerprint in class Scanpublic Map<String,Object> toMap(int maxCols)
Scanpublic boolean isRaw()
Scan@Deprecated public boolean isSmall()
ScanisSmall in class Scanpublic boolean isScanMetricsEnabled()
ScanisScanMetricsEnabled in class Scanpublic Boolean isAsyncPrefetch()
isAsyncPrefetch in class Scanpublic int getLimit()
Scanpublic Scan.ReadType getReadType()
ScangetReadType in class Scanpublic boolean isNeedCursorResult()
isNeedCursorResult in class Scanpublic byte[] getAttribute(String name)
AttributesgetAttribute in interface AttributesgetAttribute in class OperationWithAttributesname - attribute namepublic Consistency getConsistency()
QuerygetConsistency in class Querypublic long getAttributeSize()
getAttributeSize in class OperationWithAttributespublic Map<String,byte[]> getAttributesMap()
AttributesgetAttributesMap in interface AttributesgetAttributesMap in class OperationWithAttributespublic Boolean getLoadColumnFamiliesOnDemandValue()
QuerygetLoadColumnFamiliesOnDemandValue in class Querypublic int getPriority()
getPriority in class OperationWithAttributespublic Map<byte[],TimeRange> getColumnFamilyTimeRange()
QuerygetColumnFamilyTimeRange in class Querypublic int getReplicaId()
QuerygetReplicaId in class Querypublic boolean doLoadColumnFamiliesOnDemand()
QuerydoLoadColumnFamiliesOnDemand in class Querypublic String getId()
OperationWithAttributesgetId in class OperationWithAttributespublic IsolationLevel getIsolationLevel()
QuerygetIsolationLevel in class Querypublic Authorizations getAuthorizations() throws DeserializationException
QuerygetAuthorizations in class QueryDeserializationExceptionpublic String toString(int maxCols)
Operationpublic String toString()
Operationpublic Map<String,Object> toMap()
Operationpublic String toJSON(int maxCols) throws IOException
OperationtoJSON in class OperationmaxCols - a limit on the number of columns to include in the JSONIOExceptionpublic String toJSON() throws IOException
OperationtoJSON in class OperationIOExceptionCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.