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
FieldsModifier and TypeFieldDescriptionprivate ColumnCountprivate final ColumnCount[]Contains the list of columns that the ExplicitColumnTracker is tracking.private intprivate longKeeps track of the latest timestamp included for current column.private final intprivate final intprivate long -
Constructor Summary
ConstructorsConstructorDescriptionExplicitColumnTracker(NavigableSet<byte[]> columns, int minVersions, int maxVersions, long oldestUnexpiredTS) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidThe 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.booleandone()Done when there are no more columns to match against.voiddoneWithColumn(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 columnbooleanisDone(long timestamp) Give the tracker a chance to declare it's done based on only the timestamp to allow an early out.private booleanisExpired(long timestamp) voidreset()Resets the Matcherprivate voidresetTS()private booleansameAsPreviousTS(long timestamp) private voidsetTS(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:
donein interfaceColumnTracker
-
getColumnHint
Description copied from interface:ColumnTrackerUsed 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:
getColumnHintin 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_COLandScanQueryMatcher.MatchCode.SEEK_NEXT_ROW.- Specified by:
checkColumnin 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:ColumnTrackerKeeps 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_COLandScanQueryMatcher.MatchCode.INCLUDE_AND_SEEK_NEXT_ROW. Implementations which include all the columns could just returnScanQueryMatcher.MatchCode.INCLUDEin theColumnTracker.checkColumn(ExtendedCell, byte)method and perform all the operations in this checkVersions method.- Specified by:
checkVersionsin 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:ColumnTrackerResets the Matcher- Specified by:
resetin interfaceColumnTracker
-
resetTS
-
setTS
-
sameAsPreviousTS
-
isExpired
-
doneWithColumn
Description copied from interface:ColumnTrackerThis 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:
doneWithColumnin interfaceColumnTracker
-
getNextRowOrNextColumn
Description copied from interface:ColumnTrackerRetrieve the MatchCode for the next row or column- Specified by:
getNextRowOrNextColumnin interfaceColumnTracker
-
isDone
Description copied from interface:ColumnTrackerGive the tracker a chance to declare it's done based on only the timestamp to allow an early out.- Specified by:
isDonein interfaceColumnTracker- Returns:
trueto early out based on timestamp.
-
beforeShipped
Description copied from interface:ShipperListenerThe action that needs to be performed beforeShipper.shipped()is performed- Specified by:
beforeShippedin interfaceShipperListener- Throws:
IOException
-