@InterfaceAudience.Private public final class ImmutableScan extends Scan
Scan.ReadType
Modifier and Type | Field and Description |
---|---|
private Scan |
delegateScan |
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()
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
|
(package private) long |
getMvccReadPoint()
Get the mvcc read point used to open a scanner.
|
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.
|
(package private) Scan |
resetMvccReadPoint()
Set the mvcc read point to -1 which means do not use it.
|
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
|
(package private) Scan |
setMvccReadPoint(long mvccReadPoint)
Set the mvcc read point used to open a scanner.
|
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, setStopRow
private final Scan delegateScan
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()
,
n
@Deprecated public Scan setTimeStamp(long timestamp)
Scan
setTimeStamp
in class Scan
timestamp
- version timestampScan.setMaxVersions()
,
n * @deprecated As of release 2.0.0, this will be removed in HBase
3.0.0. Use {@link #setTimestamp(long)} instead
public Scan setTimestamp(long timestamp)
Scan
setTimestamp
in class Scan
timestamp
- version timestampScan.setMaxVersions()
,
n
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, exclusive npublic 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 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 Scan
startRow
- 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)
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) 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 Scan
stopRow
- 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)
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.
This CANNOT be used in combination with withStartRow and/or withStopRow. Such a combination will yield unexpected and even undefined results.
setStartStopRowForPrefixScan
in class Scan
rowPrefix
- the prefix all rows must start with. (Set null to remove the filter.) npublic Scan readAllVersions()
Scan
readAllVersions
in class Scan
public Scan readVersions(int versions)
Scan
readVersions
in class Scan
versions
- specified number of versions for each column npublic 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 qualifier npublic 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 order npublic Scan setAllowPartialResults(boolean allowPartialResults)
Scan
setAllowPartialResults
in class Scan
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
small
- set if that should use read type of PREADScan.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)
Query
public Scan setACL(String user, Permission perms)
Query
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
. nsetOneRowLimit
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. n
setReadType
in class Scan
Scan setMvccReadPoint(long mvccReadPoint)
Scan
setMvccReadPoint
in class Scan
Scan resetMvccReadPoint()
Scan
resetMvccReadPoint
in class Scan
public Scan setNeedCursorResult(boolean needCursorResult)
Scan
Result.isCursor()
Result.getCursor()
Cursor
setNeedCursorResult
in class Scan
public long getMaxResultSize()
Scan
Scan.setMaxResultSize(long)
getMaxResultSize
in class Scan
public Map<byte[],NavigableSet<byte[]>> getFamilyMap()
Scan
getFamilyMap
in class Scan
public int numFamilies()
Scan
numFamilies
in class Scan
public boolean hasFamilies()
Scan
hasFamilies
in class Scan
public byte[][] getFamilies()
Scan
getFamilies
in class Scan
public byte[] getStartRow()
Scan
getStartRow
in class Scan
public boolean includeStartRow()
Scan
includeStartRow
in class Scan
public byte[] getStopRow()
Scan
getStopRow
in class Scan
public boolean includeStopRow()
Scan
includeStopRow
in class Scan
public int getMaxVersions()
Scan
getMaxVersions
in class Scan
public int getBatch()
Scan
public int getMaxResultsPerColumnFamily()
Scan
getMaxResultsPerColumnFamily
in class Scan
public int getRowOffsetPerColumnFamily()
Scan
getRowOffsetPerColumnFamily
in class Scan
public int getCaching()
Scan
getCaching
in class Scan
public TimeRange getTimeRange()
Scan
getTimeRange
in class Scan
public boolean hasFilter()
Scan
public boolean getCacheBlocks()
Scan
getCacheBlocks
in class Scan
public boolean isReversed()
Scan
isReversed
in class Scan
public boolean getAllowPartialResults()
Scan
ResultScanner.next()
getAllowPartialResults
in class Scan
public byte[] getACL()
Query
public Map<String,Object> getFingerprint()
Scan
getFingerprint
in class Scan
public Map<String,Object> toMap(int maxCols)
Scan
public boolean isRaw()
Scan
@Deprecated public boolean isSmall()
Scan
isSmall
in class Scan
public boolean isScanMetricsEnabled()
Scan
isScanMetricsEnabled
in class Scan
public Boolean isAsyncPrefetch()
isAsyncPrefetch
in class Scan
public int getLimit()
Scan
public Scan.ReadType getReadType()
Scan
getReadType
in class Scan
long getMvccReadPoint()
Scan
getMvccReadPoint
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()
Query
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()
Query
getIsolationLevel
in class Query
public Authorizations getAuthorizations() throws DeserializationException
Query
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–2020 The Apache Software Foundation. All rights reserved.