Class ThetaJoinNode

  • All Implemented Interfaces:
    java.lang.Cloneable
    Direct Known Subclasses:
    NestedLoopJoinNode, SortMergeJoinNode

    public abstract class ThetaJoinNode
    extends PlanNode
    PlanNode representing the FROM clause in a SELECT operation. This is the relational algebra ThetaJoin operator.
    • Field Detail

      • joinType

        public JoinType joinType
        The type of the join operation to perform. Note that not all join implementations can necessarily implement all possible join types.
      • predicate

        public Expression predicate
        Join condition.
      • leftSchema

        protected Schema leftSchema
        The cached schema of the left subplan, used for join-predicate evaluation.
      • leftStats

        protected java.util.ArrayList<ColumnStats> leftStats
        The cached statistics of the left subplan, used for cost estimation.
      • rightSchema

        protected Schema rightSchema
        The cached schema of the right subplan, used for join-predicate evaluation.
      • rightStats

        protected java.util.ArrayList<ColumnStats> rightStats
        The cached statistics of the right subplan, used for cost estimation.
      • schemaSwapped

        protected boolean schemaSwapped
        True if the output schema of this node is swapped. If this flag is true then tuples from the left subplan will be on the right of joined results and so forth, but if the flag is false then the tuples from the left subplan will be on the left of the joined results. The schema and the statistics values reflect the state of this flag, after PlanNode.prepare() has been called.
    • Constructor Detail

      • ThetaJoinNode

        public ThetaJoinNode​(PlanNode leftChild,
                             PlanNode rightChild,
                             JoinType joinType,
                             Expression predicate)
        Constructs a ThetaJoinNode that joins the tuples from the left and right subplans, using the specified join type and join predicate.
        Parameters:
        leftChild - the left relation
        rightChild - the right relation
        joinType - the type of join operation to perform
        predicate - the join condition
    • Method Detail

      • joinTuples

        protected Tuple joinTuples​(Tuple left,
                                   Tuple right)
        Combine the left tuple and the right tuple. If schemaSwapped is set to true, the tuples are copied in the opposite order. This can only happen if swap() was called an odd number of times, switching the left and right subtrees.
        Parameters:
        left - the left tuple
        right - the right tuple
        Returns:
        the combined tuple
      • initialize

        public void initialize()
        Do initialization for the join operation. Resets state variables. Initialize both children.
        Overrides:
        initialize in class PlanNode
      • prepareSchemaStats

        protected void prepareSchemaStats()
        This helper method can be used by the PlanNode.prepare() method in subclasses, to compute the output schema and initial stats of the join operation. This method is provided because it takes the schemaSwapped flag into account when ordering the schema and stats.
      • swap

        public void swap()
        Swaps the left child and right child subtrees. Ensures that the schema of the node does not change in the swap, so that this is still a valid query plan.
      • isSwapped

        public boolean isSwapped()
        Returns true if the schema is swapped in this theta join node, false otherwise.
        Returns:
        true if the schema is swapped in this theta join node, false otherwise.