@API(value=INTERNAL) public class FilterSatisfiedMask extends Object
QueryComponent
to determine whether a filter and any
sub-filters or child components have been satisfied. This can be used to track which sub-components
of a given filter have already been satisfied by a planned query and which ones might require
an additional filter on the returned results.Modifier and Type | Class and Description |
---|---|
class |
FilterSatisfiedMask.FilterMismatchException
Thrown in instances where one expects the underlying filter associated with
another
FilterSatisfiedMask to match this one but they do not. |
class |
FilterSatisfiedMask.FilterNotFoundException
Thrown if the user requests a child mask from a component, but the mask does
not contain that component in any of its children.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allSatisfied()
Determine if the whole filter has been satisfied.
|
FilterSatisfiedMask |
getChild(QueryComponent childFilter)
Return the child mask associated with a child of the mask's filter.
|
List<FilterSatisfiedMask> |
getChildren()
Get the list of children of this filter.
|
KeyExpression |
getExpression()
Get the expression that satisfied this filter.
|
QueryComponent |
getFilter()
Get the filter that this mask is masking.
|
QueryComponent |
getUnsatisfiedFilter()
Construct a
QueryComponent that is equal to the original QueryComponent
but with any satisfied filters removed. |
List<QueryComponent> |
getUnsatisfiedFilters()
Create a list of filters that are not satisfied.
|
boolean |
isSatisfied()
Return whether this filter is known to have been satisfied.
|
void |
mergeWith(FilterSatisfiedMask other)
Merge in another mask over the same filter.
|
static FilterSatisfiedMask |
of(QueryComponent filter)
Create a mask around a
QueryComponent . |
void |
reset()
Reset this mask so all filters are marked as unsatisfied.
|
void |
setExpression(KeyExpression expression)
Set the expression that satisfied this filter.
|
void |
setSatisfied(boolean satisfied)
Set whether this filter has been satisfied.
|
String |
toString() |
public boolean isSatisfied()
true
if someone has already performed a traversal and marked
this filter as satisfied.public void setSatisfied(boolean satisfied)
true
, this
means that the filter is no longer needed because a query plan has already
been able to filter out any records that would match it. Setting it to
false
means that it might still be needed in some kind of post-filter.
In general, users should use reset()
if they need to say that
a filter has not been satisfied, as (unlike this method), that method traverses
down the children of this filter and recursively marks them all as
unsatisfied.satisfied
- whether this filter has been satisfied already@Nullable public KeyExpression getExpression()
null
if the filter
has not been satisfied or if the expression was not set.null
public void setExpression(@Nullable KeyExpression expression)
null
value, though it should be set to
null
if the filter is being marked as unsatisfied for
whatever reason. However, users should generally call reset()
if that is the case as that method will recursively reset all
of this mask's children as well.expression
- the expression that satisifed this filter@Nonnull public QueryComponent getFilter()
@Nonnull public List<FilterSatisfiedMask> getChildren()
@Nonnull public FilterSatisfiedMask getChild(@Nonnull QueryComponent childFilter)
FilterSatisfiedMask.FilterNotFoundException
.childFilter
- a child of the mask's filterFilterSatisfiedMask.FilterNotFoundException
- if the given filter is not associated with any of the mask's childrenpublic void reset()
@Nonnull public List<QueryComponent> getUnsatisfiedFilters()
@Nullable public QueryComponent getUnsatisfiedFilter()
QueryComponent
that is equal to the original QueryComponent
but with any satisfied filters removed. In other words, if one has been able to
satisfy some sub-component of this filter through something like an index scan, then
that part of the filter will be removed from the filter. If the entire filter has
been satisfied, this will return null
public boolean allSatisfied()
true
. Otherwise, if the filter
is a type where if the children have been satisfied, the filter has also been satisfied,
then this traverses down the children to see if they have all been satisfied. It will
then return true
if every child is satisfied and false
otherwise.
If this filter is unsatisfied and it does not traverse down this mask's children,
then it will return false
.
This is supposed to be functionally equivalent to calling getUnsatisfiedFilter()
and checking to see if the result is null
. This does not attempt to
construct the unsatisfied filter if one exists, so this should be cheaper to call.
public void mergeWith(@Nonnull FilterSatisfiedMask other)
FilterSatisfiedMask.FilterMismatchException
if
the mask provided is not a filter over the same filter as this mask. The other
mask's filter must be reference-equal to this mask's filter, not just logically equal.other
- another mask over the same filterFilterSatisfiedMask.FilterMismatchException
- if other
is not a mask of the same filter as this mask@Nonnull public static FilterSatisfiedMask of(@Nonnull QueryComponent filter)
QueryComponent
. This will traverse down any children of the
filter and produce a full tree. It initializes all filters to being unsatisfied.filter
- the filter to create the mask for