Class Correlate

  • All Implemented Interfaces:
    java.lang.Cloneable, RelOptNode, RelNode
    Direct Known Subclasses:
    EnumerableCorrelate, LogicalCorrelate

    public abstract class Correlate
    extends BiRel
    A relational operator that performs nested-loop joins.

    It behaves like a kind of Join, but works by setting variables in its environment and restarting its right-hand input.

    Correlate is not a join since: typical rules should not match Correlate.

    A Correlate is used to represent a correlated query. One implementation strategy is to de-correlate the expression.

    Mapping of physical operations to logical ones
    Physical operationLogical operation
    NestedLoopsCorrelate(A, B, regular)
    NestedLoopsOuterCorrelate(A, B, outer)
    NestedLoopsSemiCorrelate(A, B, semi)
    NestedLoopsAntiCorrelate(A, B, anti)
    HashJoinEquiJoin(A, B)
    HashJoinOuterEquiJoin(A, B, outer)
    HashJoinSemiSemiJoin(A, B, semi)
    HashJoinAntiSemiJoin(A, B, anti)
    See Also:
    CorrelationId
    • Constructor Detail

      • Correlate

        protected Correlate​(RelOptCluster cluster,
                            RelTraitSet traits,
                            RelNode left,
                            RelNode right,
                            CorrelationId correlationId,
                            ImmutableBitSet requiredColumns,
                            SemiJoinType joinType)
        Creates a Correlate.
        Parameters:
        cluster - Cluster this relational expression belongs to
        left - Left input relational expression
        right - Right input relational expression
        correlationId - Variable name for the row of left input
        requiredColumns - Set of columns that are used by correlation
        joinType - Join type
      • Correlate

        public Correlate​(RelInput input)
        Creates a Correlate by parsing serialized output.
        Parameters:
        input - Input representation
    • Method Detail

      • isValid

        public boolean isValid​(Litmus litmus,
                               RelNode.Context context)
        Description copied from interface: RelNode
        Returns whether this relational expression is valid.

        If assertions are enabled, this method is typically called with litmus = THROW, as follows:

        assert rel.isValid(Litmus.THROW)

        This signals that the method can throw an AssertionError if it is not valid.

        Specified by:
        isValid in interface RelNode
        Overrides:
        isValid in class AbstractRelNode
        Parameters:
        litmus - What to do if invalid
        context - Context for validity checking
        Returns:
        Whether relational expression is valid
      • copy

        public Correlate copy​(RelTraitSet traitSet,
                              java.util.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
      • getCorrelationId

        public CorrelationId getCorrelationId()
        Returns the correlating expressions.
        Returns:
        correlating expressions
      • getCorrelVariable

        public java.lang.String getCorrelVariable()
        Description copied from interface: RelNode
        Returns the name of the variable which is to be implicitly set at runtime each time a row is returned from the first input of this relational expression; or null if there is no variable.
        Specified by:
        getCorrelVariable in interface RelNode
        Overrides:
        getCorrelVariable in class AbstractRelNode
        Returns:
        Name of correlating variable, or null
      • getRequiredColumns

        public ImmutableBitSet getRequiredColumns()
        Returns the required columns in left relation required for the correlation in the right.
        Returns:
        columns in left relation required for the correlation in the right
      • getVariablesSet

        public java.util.Set<CorrelationId> getVariablesSet()
        Description copied from interface: RelNode
        Returns the variables that are set in this relational expression but also used and therefore not available to parents of this relational expression.

        Note: only Correlate should set variables.

        Specified by:
        getVariablesSet in interface RelNode
        Overrides:
        getVariablesSet in class AbstractRelNode
        Returns:
        Names of variables which are set in this relational expression