Interface PhysicalNode

All Superinterfaces:
Cloneable, RelNode, RelOptNode
All Known Subinterfaces:
EnumerableRel
All Known Implementing Classes:
CassandraToEnumerableConverter, CsvTableScan, CsvTableScan, ElasticsearchToEnumerableConverter, EnumerableAggregate, EnumerableBatchNestedLoopJoin, EnumerableCalc, EnumerableCollect, EnumerableCorrelate, EnumerableFilter, EnumerableHashJoin, EnumerableInterpreter, EnumerableIntersect, EnumerableLimit, EnumerableLimitSort, EnumerableMatch, EnumerableMergeJoin, EnumerableMinus, EnumerableNestedLoopJoin, EnumerableProject, EnumerableRepeatUnion, EnumerableSort, EnumerableSortedAggregate, EnumerableTableFunctionScan, EnumerableTableModify, EnumerableTableScan, EnumerableTableSpool, EnumerableUncollect, EnumerableUnion, EnumerableValues, EnumerableWindow, GeodeToEnumerableConverter, JdbcToEnumerableConverter, MongoToEnumerableConverter, PigToEnumerableConverter, SparkToEnumerableConverter, SplunkTableScan

public interface PhysicalNode
extends RelNode
Physical node in a planner that is capable of doing physical trait propagation and derivation.

How to use?

  1. Enable top-down optimization by setting VolcanoPlanner.setTopDownOpt(boolean).
  2. Let your convention's rel interface extends PhysicalNode, see EnumerableRel as an example.
  3. Each physical operator overrides any one of the two methods: passThrough(RelTraitSet) or passThroughTraits(RelTraitSet) depending on your needs.
  4. Choose derive mode for each physical operator by overriding getDeriveMode().
  5. If the derive mode is DeriveMode.OMAKASE, override method derive(List) in the physical operator, otherwise, override derive(RelTraitSet, int) or deriveTraits(RelTraitSet, int).
  6. Mark your enforcer operator by overriding RelNode.isEnforcer(), see Sort.isEnforcer() as an example. This is important, because it can help VolcanoPlanner avoid unnecessary trait propagation and derivation, therefore improve optimization efficiency.
  7. Implement Convention.enforce(RelNode, RelTraitSet) in your convention, which generates appropriate physical enforcer. See EnumerableConvention as example. Simply return null if you don't want physical trait enforcement.
  • Method Details

    • passThrough

      default RelNode passThrough​(RelTraitSet required)
      Pass required traitset from parent node to child nodes, returns new node after traits is passed down.
    • passThroughTraits

      default Pair<RelTraitSet,​List<RelTraitSet>> passThroughTraits​(RelTraitSet required)
      Pass required traitset from parent node to child nodes, returns a pair of traits after traits is passed down.

      Pair.left: the new traitset

      Pair.right: the list of required traitsets for child nodes

    • derive

      default RelNode derive​(RelTraitSet childTraits, int childId)
      Derive traitset from child node, returns new node after traits derivation.
    • deriveTraits

      default Pair<RelTraitSet,​List<RelTraitSet>> deriveTraits​(RelTraitSet childTraits, int childId)
      Derive traitset from child node, returns a pair of traits after traits derivation.

      Pair.left: the new traitset

      Pair.right: the list of required traitsets for child nodes

    • derive

      default List<RelNode> derive​(List<List<RelTraitSet>> inputTraits)
      Given a list of child traitsets, inputTraits.size() == getInput().size(), returns node list after traits derivation. This method is called ONLY when the derive mode is OMAKASE.
    • getDeriveMode

      default DeriveMode getDeriveMode()
      Returns mode of derivation.