Interface MatchCandidate

  • All Known Implementing Classes:
    PrimaryScanMatchCandidate, ValueIndexScanMatchCandidate

    public interface MatchCandidate
    Interface to represent a match candidate. A match candidate on code level is just a name and a data flow graph that can be matched against a query graph. The match candidate does not keep the root to the graph to be matched but rather an instance of ExpressionRefTraversal to allow for navigation of references within the candidate. Match candidates also allow for creation of scans over the materialized data, e.g. the index for an ValueIndexScanMatchCandidate or the primary range for a PrimaryScanMatchCandidate, given appropriate ComparisonRanges which usually are the direct result of graph matching.
    • Method Detail

      • getName

        @Nonnull
        String getName()
        Returns the name of the match candidate. If this candidate represents and index, it will be the name of the index.
        Returns:
        the name of this match candidate
      • getTraversal

        @Nonnull
        ExpressionRefTraversal getTraversal()
        Returns the traversal object for this candidate. The traversal object can either be computed up-front when the candidate is created or lazily when this method is invoked. It is, however, necessary that the traversal once computed is stable, meaning the object returned by implementors of this method must always return the same object.
        Returns:
        the traversal associated for this match candidate
      • getAlternativeKeyExpression

        @Nonnull
        KeyExpression getAlternativeKeyExpression()
        This method returns a key expression that can be used to actually compute the the keys of this candidate for a given record. The current expression hierarchy cannot be evaluated at runtime (in general). This key expression helps representing compensation or part of compensation if needed.
        Returns:
        a key expression that can be evaluated based on a base record
      • computeBoundParameterPrefixMap

        default Map<CorrelationIdentifier,​ComparisonRange> computeBoundParameterPrefixMap​(@Nonnull
                                                                                                MatchInfo matchInfo)
        Computes a map from CorrelationIdentifier to ComparisonRange that is physically compatible with a scan over the materialized version of the match candidate, so e.g. for an ValueIndexScanMatchCandidate that would be the scan over the index. As matching progresses it finds mappings from parameters to corresponding comparison ranges. Matching, however, is not sensitive to whether such a binding could actually be used in an index scan. In fact, in a different maybe future record layer with improved physical operators this method should be revised to account for those improvements. For now, we only consider a prefix of said mappings that consist of n equality-bound mappings and stops either at an inequality bound parameter or before a unbound parameter.
        Parameters:
        matchInfo - match info
        Returns:
        a map containing parameter to comparison range mappings for a prefix of parameters that is compatible with a physical scan over the materialized view (of the candidate)
      • toScanExpression

        @Nonnull
        RelationalExpression toScanExpression​(@Nonnull
                                              List<ComparisonRange> comparisonRanges,
                                              boolean isReverse)
        Creates a logical expression that represents a scan over the materialized candidate data. This method is expected to be implemented by specific implementations of MatchCandidate.
        Parameters:
        comparisonRanges - a List of ComparisonRanges to be applied
        isReverse - an indicator whether this expression should conceptually flow data in an ascending (forward) or descending (backward or reverse) order
        Returns:
        a new RelationalExpression