Interface QueryPredicate

    • 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 that EVAL(p) denotes the outcome of the evaluation of a predicate. A predicate p1 implies some other predicate p2 if
             
             (EVAL(p1, recordBindings) == true) -> (EVAL(p2, recordBindings) == true)
             
         
        for all recordBindings possibly contained in a stream of records that are potentially being flowed at execution time. If p1 implies p2, this method returns an instance of class PredicateMultiMap.PredicateMapping which should give the caller all necessary info to change p2 to COMP(p2) in a way make the opposite also true:
             
             (EVAL(p1, recordBindings) == true) <-> (EVAL(COMP(p2), recordBindings) == true)
             
         
        Note that this method takes special care when placeholders are involved as this method is called during index matching with candidates graphs. A placeholder by itself cannot be executed. In order for the place holder to match it has to partake in a relationship with a query predicate that tells the placeholder the specific comparison and bounds it operates over. In some sends this expresses a kind of polymorphism of the placeholder that is bound to a specific predicate only in the presence of a sargable predicate (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 implies p2 but, i.e., x = 5 implies true but in order for true to
             imply x = 5, the compensation has to be applied such that COMP(p2) becomes true ^ 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 implies p2 but, i.e., x = 5 implies x COMPARISONRANGE but only if
             COMPARISONRANGE is bound to [5, 5] but in order for x COMPARISONRANGE to
             imply x = 5, the compensation has to be applied such that COMP(p2) becomes x = 5.
         

        Example 3

             
             p1: x = 5
             p2: y COMPARISONRANGE (placeholder)
        
             result: Optional.empty()
             
             p1 does not imply p2, i.e., x = 5 does not imply y COMPARISONRANGE.
         
        Note: This method is expected to return a meaningful non-empty result if called with a candidate predicate that also represents a tautology.
        Parameters:
        aliasMap - the current alias map
        candidatePredicate - another predicate (usually in a match candidate)
        Returns:
        Optional(predicateMapping) if this implies candidatePredicate where predicateMapping is an new instance of PredicateMultiMap.PredicateMapping that captures potential bindings and compensation for candidatePredicate such that candidatePredicate to also imply this, Optional.empty() otherwise
      • 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