Class SortMergeJoinNode

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class SortMergeJoinNode
    extends ThetaJoinNode
    This class implements the basic sort-merge join algorithm for use in join evaluation. This join node is only useful for equijoins, but it has the benefit that it can compute full outer joins easily, where the nested-loops join algorithm is unable to do so.
    • 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 sort-merge join 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 sort-merge 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()
        Sort-merge join produces results in the same order as the children. (That's kinda the point.)
        Specified by:
        resultsOrderedBy in class PlanNode
        Returns:
        true always
      • supportsMarking

        public boolean supportsMarking()
        This plan-node does not support marking.
        Overrides:
        supportsMarking in class PlanNode
        Returns:
        true if the node supports position marking, false otherwise.
      • requiresLeftMarking

        public boolean requiresLeftMarking()
        This plan-node does not require marking on the left child-plan.
        Overrides:
        requiresLeftMarking in class PlanNode
        Returns:
        true if the node requires that its left child supports marking, false otherwise.
      • requiresRightMarking

        public boolean requiresRightMarking()
        This plan-node requires marking on the right child-plan.
        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()
        Description copied from class: PlanNode
        Gets the next tuple that fulfills the conditions for this plan node. If the node has a child, it should call getNextTuple() on the child. If the node is a leaf, the tuple comes from some external source such as a table file, the network, etc.
        Specified by:
        getNextTuple in class PlanNode
        Returns:
        the next tuple to be generated by this plan, or null if the plan has finished generating plan nodes.
      • 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()
        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
      • 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