Class VectorMatch
- java.lang.Object
-
- org.apache.druid.query.filter.vector.VectorMatch
-
- All Implemented Interfaces:
ReadableVectorMatch
public class VectorMatch extends Object implements ReadableVectorMatch
Implementation class for ReadableVectorMatch. Also adds some useful methods, like "addAll", "removeAll", and "copyFrom".
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VectorMatch
addAll(ReadableVectorMatch other, VectorMatch scratch)
Adds all rows from "other" to this object, using "scratch" as scratch space if needed.static ReadableVectorMatch
allFalse()
Creates a match that matches nothing.static ReadableVectorMatch
allTrue(int numRows)
Creates a match that matches everything up to "numRows".void
copyFrom(ReadableVectorMatch other)
Copies "other" into this object, and returns a reference to this object.int[]
getSelection()
Returns an array of indexes into the current batch.int
getSelectionSize()
Returns the number of valid values in the array from "getSelection".boolean
isAllFalse()
Checks if this match has accepted *nothing*.boolean
isAllTrue(int vectorSize)
Checks if this match has accepted every row in the vector.boolean
isValid(ReadableVectorMatch mask)
Checks if this match is valid (increasing row numbers, no out-of-range row numbers).VectorMatch
removeAll(ReadableVectorMatch other)
Removes all rows from this object that occur in "other", in place, and returns a reference to this object.VectorMatch
setSelectionSize(int newSelectionSize)
Sets the valid selectionSize, and returns a reference to this object.String
toString()
static VectorMatch
wrap(int[] selection)
Creates a new match object with selectionSize = 0, and the provided array as a backing array.
-
-
-
Method Detail
-
allTrue
public static ReadableVectorMatch allTrue(int numRows)
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
public static ReadableVectorMatch allFalse()
Creates a match that matches nothing.
-
wrap
public static VectorMatch wrap(int[] selection)
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:ReadableVectorMatch
Checks if this match has accepted every row in the vector.- Specified by:
isAllTrue
in 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:ReadableVectorMatch
Checks if this match has accepted *nothing*.- Specified by:
isAllFalse
in interfaceReadableVectorMatch
-
isValid
public boolean isValid(@Nullable ReadableVectorMatch mask)
Description copied from interface:ReadableVectorMatch
Checks 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:
isValid
in interfaceReadableVectorMatch
- Parameters:
mask
- if provided, checks if this match is a subset of the mask.
-
removeAll
public VectorMatch removeAll(ReadableVectorMatch other)
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
public VectorMatch addAll(ReadableVectorMatch other, VectorMatch scratch)
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
public void copyFrom(ReadableVectorMatch other)
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:ReadableVectorMatch
Returns 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:
getSelection
in interfaceReadableVectorMatch
-
getSelectionSize
public int getSelectionSize()
Description copied from interface:ReadableVectorMatch
Returns the number of valid values in the array from "getSelection".- Specified by:
getSelectionSize
in interfaceReadableVectorMatch
-
setSelectionSize
public VectorMatch setSelectionSize(int newSelectionSize)
Sets the valid selectionSize, and returns a reference to this object.
-
-