Interface QueryPredicate
-
- All Superinterfaces:
Bindable
,Correlated<QueryPredicate>
,PlanHashable
- All Known Subinterfaces:
PredicateWithValue
- All Known Implementing Classes:
AndOrPredicate
,AndPredicate
,ConstantPredicate
,ExistsPredicate
,NotPredicate
,OrPredicate
,QueryComponentPredicate
,ValueComparisonRangePredicate
,ValueComparisonRangePredicate.Placeholder
,ValueComparisonRangePredicate.Sargable
,ValuePredicate
@API(EXPERIMENTAL) public interface QueryPredicate extends Bindable, PlanHashable, Correlated<QueryPredicate>
Class to model the concept of a predicate. A predicate is a construct that can be evaluated using three-values logic for a set of given inputs. The caller can then use that result to take appropriate action, e.g. filter a record out of a set of records, etc.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.query.plan.temp.Correlated
Correlated.BoundEquivalence
-
Nested classes/interfaces inherited from interface com.apple.foundationdb.record.PlanHashable
PlanHashable.PlanHashKind
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <M extends Message>
Booleaneval(FDBRecordStoreBase<M> store, EvaluationContext context, FDBRecord<M> record, M message)
default Set<PredicateMultiMap.PredicateMapping>
findImpliedMappings(@NonNull AliasMap aliasMap, Iterable<QueryPredicate> candidatePredicates)
Method to find all mappings of this predicate in anIterable
of candidate predicates.default Optional<PredicateMultiMap.PredicateMapping>
impliesCandidatePredicate(@NonNull AliasMap aliasMap, QueryPredicate candidatePredicate)
Determines if this predicate implies some other predicate.default boolean
isTautology()
Method that indicates whether this predicate is filtering at all.-
Methods inherited from interface com.apple.foundationdb.record.query.plan.temp.Correlated
getCorrelatedTo, rebase, semanticEquals, semanticHashCode
-
Methods inherited from interface com.apple.foundationdb.record.PlanHashable
planHash, planHash
-
-
-
-
Method Detail
-
impliesCandidatePredicate
@Nonnull default Optional<PredicateMultiMap.PredicateMapping> impliesCandidatePredicate(@NonNull AliasMap aliasMap, @Nonnull QueryPredicate candidatePredicate)
Determines if this predicate implies some other predicate. Let's say thatEVAL(p)
denotes the outcome of the evaluation of a predicate. A predicatep1
implies some other predicatep2
if(EVAL(p1, recordBindings) == true) -> (EVAL(p2, recordBindings) == true)
recordBindings
possibly contained in a stream of records that are potentially being flowed at execution time. Ifp1
impliesp2
, this method returns an instance of classPredicateMultiMap.PredicateMapping
which should give the caller all necessary info to changep2
toCOMP(p2)
in a way make the opposite also true:(EVAL(p1, recordBindings) == true) <-> (EVAL(COMP(p2), recordBindings) == true)
ValueComparisonRangePredicate.Sargable
) on the query side.Examples:
Example 1
p1: x = 5 p2: true (tautology predicate) result: optional of PredicateMapping(COMP(true) => x = 5)
p1
impliesp2
but, i.e.,x = 5
impliestrue
but in order fortrue
to implyx = 5
, the compensation has to be applied such thatCOMP(p2)
becomestrue ^ x = 5
.Example 2
p1: x = 5 p2: x COMPARISONRANGE (placeholder) result: optional of PredicateMapping(COMP(x COMPARISONRANGE) => x = 5, binding b to indicate COMPARISONRANGE should be [5, 5])
p1
impliesp2
but, i.e.,x = 5
impliesx COMPARISONRANGE
but only ifCOMPARISONRANGE
is bound to[5, 5]
but in order forx COMPARISONRANGE
to implyx = 5
, the compensation has to be applied such thatCOMP(p2)
becomesx = 5
.Example 3
p1: x = 5 p2: y COMPARISONRANGE (placeholder) result: Optional.empty()
p1
does not implyp2
, i.e.,x = 5
does not implyy COMPARISONRANGE
.- Parameters:
aliasMap
- the current alias mapcandidatePredicate
- another predicate (usually in a match candidate)- Returns:
Optional(predicateMapping)
ifthis
impliescandidatePredicate
wherepredicateMapping
is an new instance ofPredicateMultiMap.PredicateMapping
that captures potential bindings and compensation forcandidatePredicate
such thatcandidatePredicate
to also implythis
,Optional.empty()
otherwise
-
findImpliedMappings
default Set<PredicateMultiMap.PredicateMapping> findImpliedMappings(@NonNull AliasMap aliasMap, @Nonnull Iterable<QueryPredicate> candidatePredicates)
Method to find all mappings of this predicate in anIterable
of candidate predicates. If no mapping can be found at all, this method will then callimpliesCandidatePredicate(AliasMap, QueryPredicate)
using a tautology predicate as candidate which by should by contract should return aPredicateMultiMap.PredicateMapping
.- Parameters:
aliasMap
- the current alias mapcandidatePredicates
- anIterable
of candiate predicates- Returns:
- a non-empty set of
PredicateMultiMap.PredicateMapping
s
-
isTautology
default boolean isTautology()
Method that indicates whether this predicate is filtering at all.- Returns:
true
if this predicate always evaluates to true,false
otherwise
-
eval
@Nullable <M extends Message> Boolean eval(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable FDBRecord<M> record, @Nullable M message)
-
-