Class ExplicitColumnTracker
java.lang.Object
org.apache.hadoop.hbase.regionserver.querymatcher.ExplicitColumnTracker
- All Implemented Interfaces:
ColumnTracker
,ShipperListener
This class is used for the tracking and enforcement of columns and numbers of versions during the
course of a Get or Scan operation, when explicit column qualifiers have been asked for in the
query. With a little magic (see
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(org.apache.hadoop.hbase.ExtendedCell, byte)
is called when a Put satisfies all other conditions of the query.getNextRowOrNextColumn(org.apache.hadoop.hbase.ExtendedCell)
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
-
Field Summary
Modifier and TypeFieldDescriptionprivate ColumnCount
private final ColumnCount[]
Contains the list of columns that the ExplicitColumnTracker is tracking.private int
private long
Keeps track of the latest timestamp included for current column.private final int
private final int
private long
-
Constructor Summary
ConstructorDescriptionExplicitColumnTracker
(NavigableSet<byte[]> columns, int minVersions, int maxVersions, long oldestUnexpiredTS) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
The action that needs to be performed beforeShipper.shipped()
is performedcheckColumn
(ExtendedCell cell, byte type) Checks if the column is present in the list of requested columns by returning the match code instance.checkVersions
(ExtendedCell cell, 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
(ExtendedCell cell) This method is used to inform the column tracker that we are done with this column.Used by matcher and scan/get to get a hint of the next column to seek to after checkColumn() returns SKIP.Retrieve the MatchCode for the next row or columnboolean
isDone
(long timestamp) Give the tracker a chance to declare it's done based on only the timestamp to allow an early out.private boolean
isExpired
(long timestamp) void
reset()
Resets the Matcherprivate void
resetTS()
private boolean
sameAsPreviousTS
(long timestamp) private void
setTS
(long timestamp)
-
Field Details
-
maxVersions
-
minVersions
-
columns
Contains the list of columns that the ExplicitColumnTracker is tracking. Each ColumnCount instance also tracks how many versions of the requested column have been returned. -
index
-
column
-
latestTSOfCurrentColumn
Keeps track of the latest timestamp included for current column. Used to eliminate duplicates. -
oldestStamp
-
-
Constructor Details
-
Method Details
-
done
Done when there are no more columns to match against.- Specified by:
done
in interfaceColumnTracker
-
getColumnHint
Description copied from interface:ColumnTracker
Used by matcher and scan/get to get a hint of the next column to seek to after checkColumn() returns SKIP. Returns the next interesting column we want, or NULL there is none (wildcard scanner). Implementations aren't required to return anything useful unless the most recent call was to checkColumn() and the return code was SKIP. This is pretty implementation detail-y, but optimizations are like that.- Specified by:
getColumnHint
in interfaceColumnTracker
- Returns:
- null, or a ColumnCount that we should seek to
-
checkColumn
Checks if the column is present in the list of requested columns by returning the match code instance. It does not check against the number of versions for the columns asked for. To do the version check, one has to callColumnTracker.checkVersions(ExtendedCell, long, byte, boolean)
method based on the return type (INCLUDE) of this method. The values that can be returned by this method areScanQueryMatcher.MatchCode.INCLUDE
,ScanQueryMatcher.MatchCode.SEEK_NEXT_COL
andScanQueryMatcher.MatchCode.SEEK_NEXT_ROW
.- Specified by:
checkColumn
in interfaceColumnTracker
- Parameters:
cell
- a cell with the column to match againsttype
- The type of the Cell- Returns:
- The match code instance.
-
checkVersions
public ScanQueryMatcher.MatchCode checkVersions(ExtendedCell cell, long timestamp, byte type, boolean ignoreCount) throws IOException Description copied from interface:ColumnTracker
Keeps track of the number of versions for the columns asked for. It assumes that the user has already checked if the cell needs to be included by calling theColumnTracker.checkColumn(ExtendedCell, byte)
method. The enum values returned by this method areScanQueryMatcher.MatchCode.SKIP
,ScanQueryMatcher.MatchCode.INCLUDE
,ScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_COL
andScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW
. Implementations which include all the columns could just returnScanQueryMatcher.MatchCode.INCLUDE
in theColumnTracker.checkColumn(ExtendedCell, byte)
method and perform all the operations in this checkVersions method.- Specified by:
checkVersions
in interfaceColumnTracker
- Parameters:
cell
- a cell with the column to match againsttimestamp
- The timestamp of the cell.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.)- Returns:
- the scan query matcher match code instance
- Throws:
IOException
- in case there is an internal consistency problem caused by a data corruption.
-
reset
Description copied from interface:ColumnTracker
Resets the Matcher- Specified by:
reset
in interfaceColumnTracker
-
resetTS
-
setTS
-
sameAsPreviousTS
-
isExpired
-
doneWithColumn
Description copied from interface:ColumnTracker
This method is used to inform the column tracker that we are done with this column. We may get this information from external filters or timestamp range and we then need to indicate this information to tracker. It is currently implemented for ExplicitColumnTracker.- Specified by:
doneWithColumn
in interfaceColumnTracker
-
getNextRowOrNextColumn
Description copied from interface:ColumnTracker
Retrieve the MatchCode for the next row or column- Specified by:
getNextRowOrNextColumn
in interfaceColumnTracker
-
isDone
Description copied from interface:ColumnTracker
Give the tracker a chance to declare it's done based on only the timestamp to allow an early out.- Specified by:
isDone
in interfaceColumnTracker
- Returns:
true
to early out based on timestamp.
-
beforeShipped
Description copied from interface:ShipperListener
The action that needs to be performed beforeShipper.shipped()
is performed- Specified by:
beforeShipped
in interfaceShipperListener
- Throws:
IOException
-