Class RelSubset

java.lang.Object
org.apache.calcite.rel.AbstractRelNode
org.apache.calcite.plan.volcano.RelSubset
All Implemented Interfaces:
Cloneable, RelOptNode, RelNode

public class RelSubset extends AbstractRelNode
Subset of an equivalence class where all relational expressions have the same physical properties.

Physical properties are instances of the RelTraitSet, and consist of traits such as calling convention and collation (sort-order).

For some traits, a relational expression can have more than one instance. For example, R can be sorted on both [X] and [Y, Z]. In which case, R would belong to the sub-sets for [X] and [Y, Z]; and also the leading edges [Y] and [].

See Also:
  • Method Details

    • isDelivered

      @API(since="1.23", status=EXPERIMENTAL) public boolean isDelivered()
    • isRequired

      @API(since="1.23", status=EXPERIMENTAL) public boolean isRequired()
    • getBest

      public @Nullable RelNode getBest()
    • getOriginal

      public @Nullable RelNode getOriginal()
    • getBestOrOriginal

      @API(since="1.27", status=INTERNAL) public RelNode getBestOrOriginal()
    • stripped

      public RelNode stripped()
      Description copied from interface: RelNode
      Returns this node without any wrapper added by the planner.
    • copy

      public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs)
      Description copied from interface: RelNode
      Creates a copy of this relational expression, perhaps changing traits and inputs.

      Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.

      Specified by:
      copy in interface RelNode
      Overrides:
      copy in class AbstractRelNode
      Parameters:
      traitSet - Trait set
      inputs - Inputs
      Returns:
      Copy of this relational expression, substituting traits and inputs
    • computeSelfCost

      public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
      Description copied from interface: RelNode
      Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

      NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

      Specified by:
      computeSelfCost in interface RelNode
      Overrides:
      computeSelfCost in class AbstractRelNode
      Parameters:
      planner - Planner for cost calculation
      mq - Metadata query
      Returns:
      Cost of this plan (not including children)
    • estimateRowCount

      public double estimateRowCount(RelMetadataQuery mq)
      Description copied from interface: RelNode
      Returns an estimate of the number of rows this relational expression will return.

      NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getRowCount(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about row count.

      Specified by:
      estimateRowCount in interface RelNode
      Overrides:
      estimateRowCount in class AbstractRelNode
      Parameters:
      mq - Metadata query
      Returns:
      Estimate of the number of rows this relational expression will return
    • explain

      public void explain(RelWriter pw)
      Description copied from interface: RelNode
      Describes the inputs and attributes of this relational expression. Each node should call super.explain, then call the RelWriter.input(String, RelNode) and RelWriter.item(String, Object) methods for each input and attribute.
      Specified by:
      explain in interface RelNode
      Overrides:
      explain in class AbstractRelNode
      Parameters:
      pw - Plan writer
    • deepEquals

      public boolean deepEquals(@Nullable Object obj)
      Description copied from class: AbstractRelNode
      Equality check for RelNode digest.

      By default this method collects digest attributes from AbstractRelNode.explainTerms(RelWriter), then compares each attribute pair. This should work well for most cases. If this method is a performance bottleneck for your project, or the default behavior can't handle your scenario properly, you can choose to override this method and AbstractRelNode.deepHashCode(). See LogicalJoin as an example.

      Specified by:
      deepEquals in interface RelNode
      Overrides:
      deepEquals in class AbstractRelNode
      Returns:
      Whether the 2 RelNodes are equivalent or have the same digest.
      See Also:
    • deepHashCode

      public int deepHashCode()
      Description copied from class: AbstractRelNode
      Compute hash code for RelNode digest.
      Specified by:
      deepHashCode in interface RelNode
      Overrides:
      deepHashCode in class AbstractRelNode
      See Also:
    • deriveRowType

      protected RelDataType deriveRowType()
      Overrides:
      deriveRowType in class AbstractRelNode
    • getParentRels

      public Collection<RelNode> getParentRels()
      Returns a list of relational expressions one of whose children is this subset. The elements of the list are distinct.
    • collectVariablesUsed

      public void collectVariablesUsed(Set<CorrelationId> variableSet)
      Description copied from interface: RelNode
      Collects variables known to be used by this expression or its descendants. By default, no such information is available and must be derived by analyzing sub-expressions, but some optimizer implementations may insert special expressions which remember such information.
      Specified by:
      collectVariablesUsed in interface RelNode
      Overrides:
      collectVariablesUsed in class AbstractRelNode
      Parameters:
      variableSet - receives variables used
    • collectVariablesSet

      public void collectVariablesSet(Set<CorrelationId> variableSet)
      Description copied from interface: RelNode
      Collects variables set by this expression. TODO: is this required?
      Specified by:
      collectVariablesSet in interface RelNode
      Overrides:
      collectVariablesSet in class AbstractRelNode
      Parameters:
      variableSet - receives variables known to be set by
    • getRels

      public Iterable<RelNode> getRels()
      Returns the rel nodes in this rel subset. All rels must have the same traits and are logically equivalent.
      Returns:
      all the rels in the subset
    • getRelList

      public List<RelNode> getRelList()
      As getRels() but returns a list.
    • contains

      public boolean contains(RelNode node)
      Returns whether this subset contains the specified relational expression.
    • getSubsetsSatisfyingThis

      @API(since="1.23", status=EXPERIMENTAL) public Stream<RelSubset> getSubsetsSatisfyingThis()
      Returns stream of subsets whose traitset satisfies current subset's traitset.
    • getSatisfyingSubsets

      @API(since="1.23", status=EXPERIMENTAL) public Stream<RelSubset> getSatisfyingSubsets()
      Returns stream of subsets whose traitset is satisfied by current subset's traitset.
    • getWinnerCost

      @API(since="1.24", status=INTERNAL) public @Nullable RelOptCost getWinnerCost()
      Returns the best cost if this subset is fully optimized or null if the subset is not fully optimized.
    • getDigest

      public String getDigest()
      Description copied from interface: RelNode
      Returns a digest string of this RelNode.

      Each call creates a new digest string, so don't forget to cache the result if necessary.

      Specified by:
      getDigest in interface RelNode
      Specified by:
      getDigest in interface RelOptNode
      Overrides:
      getDigest in class AbstractRelNode
      Returns:
      Digest string of this RelNode
      See Also: