Class MockRelOptPlanner

  • All Implemented Interfaces:
    org.apache.calcite.plan.RelOptPlanner

    public class MockRelOptPlanner
    extends org.apache.calcite.plan.AbstractRelOptPlanner
    MockRelOptPlanner is a mock implementation of the RelOptPlanner interface.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  MockRelOptPlanner.MockRuleCall
      Mock call to a planner rule.
      • Nested classes/interfaces inherited from interface org.apache.calcite.plan.RelOptPlanner

        org.apache.calcite.plan.RelOptPlanner.CannotPlanException, org.apache.calcite.plan.RelOptPlanner.Executor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private long metadataTimestamp  
      private org.apache.calcite.rel.RelNode root  
      private org.apache.calcite.plan.RelOptRule rule  
      private org.apache.calcite.rel.RelNode transformationResult  
      • Fields inherited from class org.apache.calcite.plan.AbstractRelOptPlanner

        context, costFactory
      • Fields inherited from interface org.apache.calcite.plan.RelOptPlanner

        LOGGER
    • Constructor Summary

      Constructors 
      Constructor Description
      MockRelOptPlanner​(org.apache.calcite.plan.Context context)
      Creates MockRelOptPlanner.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addRule​(org.apache.calcite.plan.RelOptRule rule)  
      org.apache.calcite.rel.RelNode changeTraits​(org.apache.calcite.rel.RelNode rel, org.apache.calcite.plan.RelTraitSet toTraits)  
      void clear()  
      org.apache.calcite.rel.RelNode ensureRegistered​(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.RelNode equivRel)  
      org.apache.calcite.rel.RelNode findBestExp()  
      long getRelMetadataTimestamp​(org.apache.calcite.rel.RelNode rel)  
      org.apache.calcite.rel.RelNode getRoot()  
      java.util.List<org.apache.calcite.plan.RelOptRule> getRules()  
      boolean isRegistered​(org.apache.calcite.rel.RelNode rel)  
      private boolean match​(org.apache.calcite.plan.RelOptRuleOperand operand, org.apache.calcite.rel.RelNode rel, java.util.List<org.apache.calcite.rel.RelNode> bindings)
      Matches a relational expression to a rule.
      private boolean matchRecursive​(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.RelNode parent, int ordinalInParent)
      Recursively matches a rule.
      org.apache.calcite.rel.RelNode register​(org.apache.calcite.rel.RelNode rel, org.apache.calcite.rel.RelNode equivRel)  
      boolean removeRule​(org.apache.calcite.plan.RelOptRule rule)  
      void setRelMetadataTimestamp​(long metadataTimestamp)
      Allow tests to tweak the timestamp.
      void setRoot​(org.apache.calcite.rel.RelNode rel)  
      • Methods inherited from class org.apache.calcite.plan.AbstractRelOptPlanner

        addLattice, addListener, addMaterialization, addRelTraitDef, checkCancel, chooseDelegate, clearRelTraitDefs, emptyTraitSet, fireRule, getContext, getCost, getCost, getCostFactory, getExecutor, getLattice, getListener, getMaterializations, getRelTraitDefs, getRuleByDescription, isRuleExcluded, mapRuleDescription, notifyChosen, notifyDiscard, notifyEquivalence, notifyTransformation, onCopy, onNewClass, registerClass, registerMetadataProviders, registerSchema, setCancelFlag, setExecutor, setImportance, setRuleDescExclusionFilter, subClasses, unmapRuleDescription
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • root

        private org.apache.calcite.rel.RelNode root
      • rule

        private org.apache.calcite.plan.RelOptRule rule
      • transformationResult

        private org.apache.calcite.rel.RelNode transformationResult
      • metadataTimestamp

        private long metadataTimestamp
    • Constructor Detail

      • MockRelOptPlanner

        public MockRelOptPlanner​(org.apache.calcite.plan.Context context)
        Creates MockRelOptPlanner.
    • Method Detail

      • setRoot

        public void setRoot​(org.apache.calcite.rel.RelNode rel)
      • getRoot

        public org.apache.calcite.rel.RelNode getRoot()
      • clear

        public void clear()
        Specified by:
        clear in interface org.apache.calcite.plan.RelOptPlanner
        Overrides:
        clear in class org.apache.calcite.plan.AbstractRelOptPlanner
      • getRules

        public java.util.List<org.apache.calcite.plan.RelOptRule> getRules()
      • addRule

        public boolean addRule​(org.apache.calcite.plan.RelOptRule rule)
      • removeRule

        public boolean removeRule​(org.apache.calcite.plan.RelOptRule rule)
      • changeTraits

        public org.apache.calcite.rel.RelNode changeTraits​(org.apache.calcite.rel.RelNode rel,
                                                           org.apache.calcite.plan.RelTraitSet toTraits)
      • findBestExp

        public org.apache.calcite.rel.RelNode findBestExp()
      • matchRecursive

        private boolean matchRecursive​(org.apache.calcite.rel.RelNode rel,
                                       org.apache.calcite.rel.RelNode parent,
                                       int ordinalInParent)
        Recursively matches a rule.
        Parameters:
        rel - Relational expression
        parent - Parent relational expression
        ordinalInParent - Ordinal of relational expression among its siblings
        Returns:
        whether match occurred
      • match

        private boolean match​(org.apache.calcite.plan.RelOptRuleOperand operand,
                              org.apache.calcite.rel.RelNode rel,
                              java.util.List<org.apache.calcite.rel.RelNode> bindings)
        Matches a relational expression to a rule.
        Parameters:
        operand - Root operand of rule
        rel - Relational expression
        bindings - Bindings, populated on successful match
        Returns:
        whether relational expression matched rule
      • register

        public org.apache.calcite.rel.RelNode register​(org.apache.calcite.rel.RelNode rel,
                                                       org.apache.calcite.rel.RelNode equivRel)
      • ensureRegistered

        public org.apache.calcite.rel.RelNode ensureRegistered​(org.apache.calcite.rel.RelNode rel,
                                                               org.apache.calcite.rel.RelNode equivRel)
      • isRegistered

        public boolean isRegistered​(org.apache.calcite.rel.RelNode rel)
      • getRelMetadataTimestamp

        public long getRelMetadataTimestamp​(org.apache.calcite.rel.RelNode rel)
        Specified by:
        getRelMetadataTimestamp in interface org.apache.calcite.plan.RelOptPlanner
        Overrides:
        getRelMetadataTimestamp in class org.apache.calcite.plan.AbstractRelOptPlanner
      • setRelMetadataTimestamp

        public void setRelMetadataTimestamp​(long metadataTimestamp)
        Allow tests to tweak the timestamp.