Class AbstractRelOptPlanner

    • Field Detail


        private static final java.util.regex.Pattern INTEGER_PATTERN
        Regular expression for integer.
      • mapDescToRule

        private final java.util.Map<java.lang.String,​RelOptRule> mapDescToRule
        Maps rule description to rule, just to ensure that rules' descriptions are unique.
      • ruleDescExclusionFilter

        private java.util.regex.Pattern ruleDescExclusionFilter
      • cancelFlag

        private final java.util.concurrent.atomic.AtomicBoolean cancelFlag
      • classes

        private final java.util.Set<java.lang.Class<? extends RelNode>> classes
      • traits

        private final java.util.Set<RelTrait> traits
      • context

        protected final Context context
        External context. Never null.
    • Constructor Detail

      • AbstractRelOptPlanner

        protected AbstractRelOptPlanner​(RelOptCostFactory costFactory,
                                        Context context)
        Creates an AbstractRelOptPlanner.
    • Method Detail

      • clear

        public void clear()
        Description copied from interface: RelOptPlanner
        Removes all internal state, including all registered rules, materialized views, and lattices.
        Specified by:
        clear in interface RelOptPlanner
      • getContext

        public Context getContext()
        Description copied from interface: RelOptPlanner
        Provides the Context created when this planner was constructed.
        Specified by:
        getContext in interface RelOptPlanner
        Never null; either an externally defined context, or a dummy context that returns null for each requested interface
      • setCancelFlag

        public void setCancelFlag​(CancelFlag cancelFlag)
        Description copied from interface: RelOptPlanner
        Does nothing.
        Specified by:
        setCancelFlag in interface RelOptPlanner
        cancelFlag - flag which the planner should periodically check
      • checkCancel

        public void checkCancel()
        Checks to see whether cancellation has been requested, and if so, throws an exception.
      • mapRuleDescription

        protected void mapRuleDescription​(RelOptRule rule)
        Registers a rule's description.
        rule - Rule
      • unmapRuleDescription

        protected void unmapRuleDescription​(RelOptRule rule)
        Removes the mapping between a rule and its description.
        rule - Rule
      • getRuleByDescription

        protected RelOptRule getRuleByDescription​(java.lang.String description)
        Returns the rule with a given description
        description - Description
        Rule with given description, or null if not found
      • setRuleDescExclusionFilter

        public void setRuleDescExclusionFilter​(java.util.regex.Pattern exclusionFilter)
        Description copied from interface: RelOptPlanner
        Sets the exclusion filter to use for this planner. Rules which match the given pattern will not be fired regardless of whether or when they are added to the planner.
        Specified by:
        setRuleDescExclusionFilter in interface RelOptPlanner
        exclusionFilter - pattern to match for exclusion; null to disable filtering
      • isRuleExcluded

        public boolean isRuleExcluded​(RelOptRule rule)
        Determines whether a given rule is excluded by ruleDescExclusionFilter.
        rule - rule to test
        true iff rule should be excluded
      • chooseDelegate

        public RelOptPlanner chooseDelegate()
        Description copied from interface: RelOptPlanner
        Negotiates an appropriate planner to deal with distributed queries. The idea is that the schemas decide among themselves which has the most knowledge. Right now, the local planner retains control.
        Specified by:
        chooseDelegate in interface RelOptPlanner
      • addMaterialization

        public void addMaterialization​(RelOptMaterialization materialization)
        Description copied from interface: RelOptPlanner
        Defines a pair of relational expressions that are equivalent.

        Typically tableRel is a LogicalTableScan representing a table that is a materialized view and queryRel is the SQL expression that populates that view. The intention is that tableRel is cheaper to evaluate and therefore if the query being optimized uses (or can be rewritten to use) queryRel as a sub-expression then it can be optimized by using tableRel instead.

        Specified by:
        addMaterialization in interface RelOptPlanner
      • registerSchema

        public void registerSchema​(RelOptSchema schema)
        Description copied from interface: RelOptPlanner
        Tells this planner that a schema exists. This is the schema's chance to tell the planner about all of the special transformation rules.
        Specified by:
        registerSchema in interface RelOptPlanner
      • getRelMetadataTimestamp

        public long getRelMetadataTimestamp​(RelNode rel)
        Description copied from interface: RelOptPlanner
        Gets a timestamp for a given rel's metadata. This timestamp is used by CachingRelMetadataProvider to decide whether cached metadata has gone stale.
        Specified by:
        getRelMetadataTimestamp in interface RelOptPlanner
        rel - rel of interest
        timestamp of last change which might affect metadata derivation
      • setImportance

        public void setImportance​(RelNode rel,
                                  double importance)
        Description copied from interface: RelOptPlanner
        Sets the importance of a relational expression.

        An important use of this method is when a RelOptRule has created a relational expression which is indisputably better than the original relational expression. The rule set the original relational expression's importance to zero, to reduce the search space. Pending rule calls are cancelled, and future rules will not fire.

        Specified by:
        setImportance in interface RelOptPlanner
        rel - Relational expression
        importance - Importance
      • registerClass

        public void registerClass​(RelNode node)
        Description copied from interface: RelOptPlanner
        Registers a class of RelNode. If this class of RelNode has been seen before, does nothing.
        Specified by:
        registerClass in interface RelOptPlanner
        node - Relational expression
      • onNewClass

        protected void onNewClass​(RelNode node)
        Called when a new class of RelNode is seen.
      • emptyTraitSet

        public RelTraitSet emptyTraitSet()
        Description copied from interface: RelOptPlanner
        Creates an empty trait set. It contains all registered traits, and the default values of any traits that have them.

        The empty trait set acts as the prototype (a kind of factory) for all subsequently created trait sets.

        Specified by:
        emptyTraitSet in interface RelOptPlanner
        Empty trait set
      • addListener

        public void addListener​(RelOptListener newListener)
        Description copied from interface: RelOptPlanner
        Adds a listener to this planner.
        Specified by:
        addListener in interface RelOptPlanner
        newListener - new listener to be notified of events
      • registerMetadataProviders

        public void registerMetadataProviders​(java.util.List<RelMetadataProvider> list)
        Description copied from interface: RelOptPlanner
        Gives this planner a chance to register one or more RelMetadataProviders in the chain which will be used to answer metadata queries.

        Planners which use their own relational expressions internally to represent concepts such as equivalence classes will generally need to supply corresponding metadata providers.

        Specified by:
        registerMetadataProviders in interface RelOptPlanner
        list - receives planner's custom providers, if any
      • addRelTraitDef

        public boolean addRelTraitDef​(RelTraitDef relTraitDef)
        Description copied from interface: RelOptPlanner
        Registers a rel trait definition. If the RelTraitDef has already been registered, does nothing.
        Specified by:
        addRelTraitDef in interface RelOptPlanner
        whether the RelTraitDef was added, as per Collection.add(E)
      • onCopy

        public void onCopy​(RelNode rel,
                           RelNode newRel)
        Description copied from interface: RelOptPlanner
        Called when a relational expression is copied to a similar expression.
        Specified by:
        onCopy in interface RelOptPlanner
      • fireRule

        protected void fireRule​(RelOptRuleCall ruleCall)
        Fires a rule, taking care of tracing and listener notification.
        ruleCall - description of rule call
      • notifyTransformation

        protected void notifyTransformation​(RelOptRuleCall ruleCall,
                                            RelNode newRel,
                                            boolean before)
        Takes care of tracing and listener notification when a rule's transformation is applied.
        ruleCall - description of rule call
        newRel - result of transformation
        before - true before registration of new rel; false after
      • notifyChosen

        protected void notifyChosen​(RelNode rel)
        Takes care of tracing and listener notification when a rel is chosen as part of the final plan.
        rel - chosen rel
      • notifyEquivalence

        protected void notifyEquivalence​(RelNode rel,
                                         java.lang.Object equivalenceClass,
                                         boolean physical)
        Takes care of tracing and listener notification when a rel equivalence is detected.
        rel - chosen rel
      • notifyDiscard

        protected void notifyDiscard​(RelNode rel)
        Takes care of tracing and listener notification when a rel is discarded
        rel - discarded rel
      • subClasses

        public java.lang.Iterable<java.lang.Class<? extends RelNode>> subClasses​(java.lang.Class<? extends RelNode> clazz)
        Returns sub-classes of relational expression.