Class NewVersionBehaviorTracker
java.lang.Object
org.apache.hadoop.hbase.regionserver.querymatcher.NewVersionBehaviorTracker
- All Implemented Interfaces:
ColumnTracker
,DeleteTracker
,ShipperListener
- Direct Known Subclasses:
VisibilityNewVersionBehaivorTracker
@Private
public class NewVersionBehaviorTracker
extends Object
implements ColumnTracker, DeleteTracker
A tracker both implementing ColumnTracker and DeleteTracker, used for mvcc-sensitive scanning. We
should make sure in one QueryMatcher the ColumnTracker and DeleteTracker is the same instance.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
A data structure which contains infos we need that happens before this node's mvcc and after the previous node's mvcc.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.regionserver.querymatcher.DeleteTracker
DeleteTracker.DeleteResult
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
private byte[][]
private CellComparator
private int
private byte[]
private int
private long
private int
private long
private byte
protected int
private int
private long
private int
-
Constructor Summary
ConstructorDescriptionNewVersionBehaviorTracker
(NavigableSet<byte[]> columns, CellComparator comparartor, int minVersion, int maxVersion, int resultMaxVersions, long oldestUnexpiredTS) Note maxVersion and minVersion must set according to cf's conf, not user's scan parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ExtendedCell cell) Add the specified cell to the list of deletes to check against for this row operation.void
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()
Returnstrue
when done.Return the comparator passed to this delete trackerUsed 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 columnprivate boolean
isDeleted
(ExtendedCell cell) This method is not idempotent, we will save some info to judge VERSION_MASKED.boolean
isDone
(long timestamp) Give the tracker a chance to declare it's done based on only the timestamp to allow an early out.boolean
isEmpty()
Returns true if there are no current delete, false otherwiseprotected long
prepare
(ExtendedCell cell) Reset the map if it is different with the last Cell.void
reset()
Resets the Matcherprotected void
void
update()
Called at the end of every StoreFile.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.regionserver.querymatcher.ColumnTracker
doneWithColumn
-
Field Details
-
lastCqArray
-
lastCqLength
-
lastCqOffset
-
lastCqTs
-
lastCqMvcc
-
lastCqType
-
columnIndex
-
countCurrentCol
-
maxVersions
-
resultMaxVersions
-
columns
-
minVersions
-
oldestStamp
-
comparator
-
delColMap
-
delFamMap
-
-
Constructor Details
-
Method Details
-
beforeShipped
Description copied from interface:ShipperListener
The action that needs to be performed beforeShipper.shipped()
is performed- Specified by:
beforeShipped
in interfaceShipperListener
- Throws:
IOException
-
prepare
Reset the map if it is different with the last Cell. Save the cq array/offset/length for next Cell.- Returns:
- If this put has duplicate ts with last cell, return the mvcc of last cell. Else return MAX_VALUE.
-
isColumnQualifierChanged
-
add
Description copied from interface:DeleteTracker
Add the specified cell to the list of deletes to check against for this row operation.This is called when a Delete is encountered in a StoreFile.
- Specified by:
add
in interfaceDeleteTracker
- Parameters:
cell
- - the delete cell
-
isDeleted
This method is not idempotent, we will save some info to judge VERSION_MASKED.- Specified by:
isDeleted
in interfaceDeleteTracker
- Parameters:
cell
- - current cell to check if deleted by a previously seen delete- Returns:
- We don't distinguish DeleteColumn and DeleteFamily. We only return code for column.
-
isEmpty
Description copied from interface:DeleteTracker
Returns true if there are no current delete, false otherwise- Specified by:
isEmpty
in interfaceDeleteTracker
-
update
Description copied from interface:DeleteTracker
Called at the end of every StoreFile.Many optimized implementations of Trackers will require an update at when the end of each StoreFile is reached.
- Specified by:
update
in interfaceDeleteTracker
-
checkColumn
Description copied from interface:ColumnTracker
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.
- Throws:
IOException
- in case there is an internal consistency problem caused by a data corruption.
-
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
- Specified by:
reset
in interfaceDeleteTracker
-
resetInternal
-
done
Description copied from interface:ColumnTracker
Returnstrue
when done.- 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
-
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.
-
getCellComparator
Description copied from interface:DeleteTracker
Return the comparator passed to this delete tracker- Specified by:
getCellComparator
in interfaceDeleteTracker
- Returns:
- the cell comparator
-