@InterfaceAudience.Private public class ExplicitColumnTracker extends Object implements ColumnTracker
ScanQueryMatcher
), we can use this matcher
for both scans and gets. The main difference is 'next' and 'done' collapse
for the scan case (since we see all columns in order), and we only reset
between rows.
This class is utilized by ScanQueryMatcher
mainly through two methods:
checkColumn(byte[], int, int, byte)
is called when a Put satisfies all other
conditions of the query.
getNextRowOrNextColumn(byte[], int, int)
is called whenever ScanQueryMatcher
believes that the current column should be skipped (by timestamp, filter etc.)
These two methods returns a
ScanQueryMatcher.MatchCode
to define what action should be taken.
This class is NOT thread-safe as queries are never multi-threaded
Constructor and Description |
---|
ExplicitColumnTracker(NavigableSet<byte[]> columns,
int minVersions,
int maxVersions,
long oldestUnexpiredTS)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
ScanQueryMatcher.MatchCode |
checkColumn(byte[] bytes,
int offset,
int length,
byte type)
Checks if the column is present in the list of requested columns by returning the match code
instance.
|
ScanQueryMatcher.MatchCode |
checkVersions(byte[] bytes,
int offset,
int length,
long timestamp,
byte type,
boolean ignoreCount)
Keeps track of the number of versions for the columns asked for.
|
boolean |
done()
Done when there are no more columns to match against.
|
void |
doneWithColumn(byte[] bytes,
int offset,
int length)
This method is used to inform the column tracker that we are done with
this column.
|
ColumnCount |
getColumnHint()
Used by matcher and scan/get to get a hint of the next column
to seek to after checkColumn() returns SKIP.
|
ScanQueryMatcher.MatchCode |
getNextRowOrNextColumn(byte[] bytes,
int offset,
int qualLength)
Retrieve the MatchCode for the next row or column
|
boolean |
isDone(long timestamp)
Give the tracker a chance to declare it's done based on only the timestamp
to allow an early out.
|
void |
reset()
Resets the Matcher
|
public ExplicitColumnTracker(NavigableSet<byte[]> columns, int minVersions, int maxVersions, long oldestUnexpiredTS)
columns
- columns specified user in queryminVersions
- minimum number of versions to keepmaxVersions
- maximum versions to return per columnoldestUnexpiredTS
- the oldest timestamp we are interested in,
based on TTLpublic boolean done()
done
in interface ColumnTracker
true
when done.public ColumnCount getColumnHint()
ColumnTracker
getColumnHint
in interface ColumnTracker
public ScanQueryMatcher.MatchCode checkColumn(byte[] bytes, int offset, int length, byte type)
ColumnTracker.checkVersions(byte[], int, int, long, byte, boolean)
method based on the return type (INCLUDE) of this method. The values that can be returned by
this method are ScanQueryMatcher.MatchCode.INCLUDE
, ScanQueryMatcher.MatchCode.SEEK_NEXT_COL
and
ScanQueryMatcher.MatchCode.SEEK_NEXT_ROW
.checkColumn
in interface ColumnTracker
type
- The type of the KeyValuepublic ScanQueryMatcher.MatchCode checkVersions(byte[] bytes, int offset, int length, long timestamp, byte type, boolean ignoreCount) throws IOException
ColumnTracker
ColumnTracker.checkColumn(byte[], int, int, byte)
method. The enum values returned by this method
are ScanQueryMatcher.MatchCode.SKIP
, ScanQueryMatcher.MatchCode.INCLUDE
,
ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL
and ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW
.
Implementations which include all the columns could just return ScanQueryMatcher.MatchCode.INCLUDE
in
the ColumnTracker.checkColumn(byte[], int, int, byte)
method and perform all the operations in this
checkVersions method.checkVersions
in interface ColumnTracker
timestamp
- The timeToLive to enforce.type
- the type of the key value (Put/Delete)ignoreCount
- indicates if the KV needs to be excluded while counting (used during
compactions. We only count KV's that are older than all the scanners' read points.)IOException
- in case there is an internal consistency problem caused by a data
corruption.public void reset()
ColumnTracker
reset
in interface ColumnTracker
public void doneWithColumn(byte[] bytes, int offset, int length)
bytes
- offset
- length
- public ScanQueryMatcher.MatchCode getNextRowOrNextColumn(byte[] bytes, int offset, int qualLength)
ColumnTracker
getNextRowOrNextColumn
in interface ColumnTracker
public boolean isDone(long timestamp)
ColumnTracker
isDone
in interface ColumnTracker
true
to early out based on timestamp.Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.