Class VectorMatch
java.lang.Object
org.apache.druid.query.filter.vector.VectorMatch
- All Implemented Interfaces:
ReadableVectorMatch
Implementation class for ReadableVectorMatch.
Also adds some useful methods, like "addAll", "removeAll", and "copyFrom".
-
Method Summary
Modifier and TypeMethodDescriptionaddAll(ReadableVectorMatch other, VectorMatch scratch) Adds all rows from "other" to this object, using "scratch" as scratch space if needed.static ReadableVectorMatchallFalse()Creates a match that matches nothing.static ReadableVectorMatchallTrue(int numRows) Creates a match that matches everything up to "numRows".voidcopyFrom(ReadableVectorMatch other) Copies "other" into this object, and returns a reference to this object.int[]Returns an array of indexes into the current batch.intReturns the number of valid values in the array from "getSelection".booleanChecks if this match has accepted *nothing*.booleanisAllTrue(int vectorSize) Checks if this match has accepted every row in the vector.booleanisValid(ReadableVectorMatch mask) Checks if this match is valid (increasing row numbers, no out-of-range row numbers).removeAll(ReadableVectorMatch other) Removes all rows from this object that occur in "other", in place, and returns a reference to this object.setSelectionSize(int newSelectionSize) Sets the valid selectionSize, and returns a reference to this object.toString()static VectorMatchwrap(int[] selection) Creates a new match object with selectionSize = 0, and the provided array as a backing array.
-
Method Details
-
allTrue
Creates a match that matches everything up to "numRows". This will often be the current vector size, but does not necessarily have to be. -
allFalse
Creates a match that matches nothing. -
wrap
Creates a new match object with selectionSize = 0, and the provided array as a backing array. -
isAllTrue
public boolean isAllTrue(int vectorSize) Description copied from interface:ReadableVectorMatchChecks if this match has accepted every row in the vector.- Specified by:
isAllTruein interfaceReadableVectorMatch- Parameters:
vectorSize- the current vector size; must be passed in since VectorMatch objects do not "know" the size of the vector they came from.
-
isAllFalse
public boolean isAllFalse()Description copied from interface:ReadableVectorMatchChecks if this match has accepted *nothing*.- Specified by:
isAllFalsein interfaceReadableVectorMatch
-
isValid
Description copied from interface:ReadableVectorMatchChecks if this match is valid (increasing row numbers, no out-of-range row numbers). Can additionally verify that the match is a subset of a provided "mask". Used by assertions and tests.- Specified by:
isValidin interfaceReadableVectorMatch- Parameters:
mask- if provided, checks if this match is a subset of the mask.
-
removeAll
Removes all rows from this object that occur in "other", in place, and returns a reference to this object. Does not modify "other". "other" cannot be the same instance as this object. -
addAll
Adds all rows from "other" to this object, using "scratch" as scratch space if needed. Does not modify "other". Returns a reference to this object. "other" and "scratch" cannot be the same instance as each other, or as this object. -
copyFrom
Copies "other" into this object, and returns a reference to this object. Does not modify "other". "other" cannot be the same instance as this object. -
getSelection
public int[] getSelection()Description copied from interface:ReadableVectorMatchReturns an array of indexes into the current batch. Only the first "getSelectionSize" are valid. Even though this array is technically mutable, it is very poor form to mutate it if you are not the owner of the VectorMatch object. The reason we use a mutable array here instead of positional getter methods, by the way, is in the hopes of keeping access to the selection vector as low-level and optimizable as possible. Potential optimizations could include making it easier for the JVM to use CPU-level vectorization, avoid method calls, etc.- Specified by:
getSelectionin interfaceReadableVectorMatch
-
getSelectionSize
public int getSelectionSize()Description copied from interface:ReadableVectorMatchReturns the number of valid values in the array from "getSelection".- Specified by:
getSelectionSizein interfaceReadableVectorMatch
-
setSelectionSize
Sets the valid selectionSize, and returns a reference to this object. -
toString
-