Class NestedLoopJoinNode

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class NestedLoopJoinNode
    extends ThetaJoinNode
    This plan node implements a nested-loop join operation, which can support arbitrary join conditions but is also the slowest join implementation.
    • Field Detail

      • logger

        private static org.apache.logging.log4j.Logger logger
        A logging object for reporting anything interesting that happens.
      • leftTuple

        private Tuple leftTuple
        Most recently retrieved tuple of the left relation.
      • rightTuple

        private Tuple rightTuple
        Most recently retrieved tuple of the right relation.
      • done

        private boolean done
        Set to true when we have exhausted all tuples from our subplans.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Checks if the argument is a plan node tree with the same structure, but not necessarily the same references.
        Specified by:
        equals in class PlanNode
        Parameters:
        obj - the object to which we are comparing
      • hashCode

        public int hashCode()
        Computes the hash-code of the nested-loop plan node.
        Specified by:
        hashCode in class PlanNode
        Returns:
        the hash code for the plan node and any subnodes it may contain.
      • toString

        public java.lang.String toString()
        Returns a string representing this nested-loop join's vital information.
        Specified by:
        toString in class PlanNode
        Returns:
        a string representing this plan-node.
      • clone

        protected PlanNode clone()
                          throws java.lang.CloneNotSupportedException
        Creates a copy of this plan node and its subtrees.
        Overrides:
        clone in class PlanNode
        Throws:
        java.lang.CloneNotSupportedException
      • resultsOrderedBy

        public java.util.List<OrderByExpression> resultsOrderedBy()
        Nested-loop joins can conceivably produce sorted results in situations where the outer relation is ordered, but we will keep it simple and just report that the results are not ordered.
        Specified by:
        resultsOrderedBy in class PlanNode
        Returns:
        If the plan node produces ordered results, this will be a list of objects specifying the ordering. If the node doesn't produce ordered results then the return-value will either be an empty list or it will be null.
      • supportsMarking

        public boolean supportsMarking()
        True if the node supports position marking.
        Overrides:
        supportsMarking in class PlanNode
        Returns:
        true if the node supports position marking, false otherwise.
      • requiresLeftMarking

        public boolean requiresLeftMarking()
        True if the node requires that its left child supports marking.
        Overrides:
        requiresLeftMarking in class PlanNode
        Returns:
        true if the node requires that its left child supports marking, false otherwise.
      • requiresRightMarking

        public boolean requiresRightMarking()
        True if the node requires that its right child supports marking.
        Overrides:
        requiresRightMarking in class PlanNode
        Returns:
        true if the node requires that its right child supports marking, false otherwise.
      • prepare

        public void prepare()
        Description copied from class: PlanNode
        This method is responsible for computing critical details about the plan node, such as the schema of the results that are produced, the estimated cost of evaluating the plan node (and its children), and statistics describing the results produced by the plan node.
        Specified by:
        prepare in class PlanNode
      • initialize

        public void initialize()
        Description copied from class: ThetaJoinNode
        Do initialization for the join operation. Resets state variables. Initialize both children.
        Overrides:
        initialize in class ThetaJoinNode
      • getNextTuple

        public Tuple getNextTuple()
        Returns the next joined tuple that satisfies the join condition.
        Specified by:
        getNextTuple in class PlanNode
        Returns:
        the next joined tuple that satisfies the join condition.
      • getTuplesToJoin

        private boolean getTuplesToJoin()
        This helper function implements the logic that sets leftTuple and rightTuple based on the nested-loops logic.
        Returns:
        true if another pair of tuples was found to join, or false if no more pairs of tuples are available to join.
      • canJoinTuples

        private boolean canJoinTuples()
      • markCurrentPosition

        public void markCurrentPosition()
        Description copied from class: PlanNode
        Marks the current tuple in the tuple-stream produced by this node. The PlanNode.resetToLastMark() method can be used to return to this tuple. Note that only one marker can be set in the tuple-stream at a time.
        Overrides:
        markCurrentPosition in class PlanNode
      • resetToLastMark

        public void resetToLastMark()
                             throws java.lang.IllegalStateException
        Description copied from class: PlanNode
        Resets the node's tuple-stream to the most recently marked position. Note that only one marker can be set in the tuple-stream at a time.
        Overrides:
        resetToLastMark in class PlanNode
        Throws:
        java.lang.IllegalStateException - if PlanNode.markCurrentPosition() hasn't yet been called on this plan-node
      • cleanUp

        public void cleanUp()
        Description copied from class: PlanNode
        Perform any necessary clean up tasks. This should probably be called when we are done with this plan node.
        Specified by:
        cleanUp in class PlanNode