Class TupleBagNode

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class TupleBagNode
    extends PlanNode
    This plan-node returns tuples from a collection specified on the node before it is prepared. This can be used to inject a set of tuples into an execution plan.
    • Field Detail

      • prepared

        private boolean prepared
      • tuples

        private java.util.ArrayList<Tuple> tuples
        The collection of tuples that are returned by this plan node.
      • currentTupleIndex

        private int currentTupleIndex
      • markedTupleIndex

        private int markedTupleIndex
    • Constructor Detail

      • TupleBagNode

        public TupleBagNode​(Schema schema)
    • Method Detail

      • addTuple

        public void addTuple​(Tuple tup)
        Adds a tuple to the bag of tuples. If the tuple is disk-backed, a copy of the tuple is stored into this node.
        Parameters:
        tup - a tuple to add to the bag of tuples
      • resultsOrderedBy

        public java.util.List<OrderByExpression> resultsOrderedBy()
        Description copied from class: PlanNode
        If the results are ordered in some way, this method returns a collection of expressions specifying what columns or expressions the results are ordered by. If the results are not ordered then this method may return either an empty list or a null value.

        When this method returns a list of ordering expressions, the order of the expressions themselves also matters. The entire set of results will be ordered by the first expression; rows with the same value for the first expression will be ordered by the second expression; etc.

        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()
        Description copied from class: PlanNode
        This method reports whether this plan node supports marking a certain point in the tuple-stream so that processing can return to that point as needed.
        Overrides:
        supportsMarking in class PlanNode
        Returns:
        true if the node supports position 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
      • 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
      • toString

        public java.lang.String toString()
        Description copied from class: PlanNode
        Reports this node and its vital parameters as a string.
        Specified by:
        toString in class PlanNode
        Returns:
        the node in string format.
      • equals

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

        public int hashCode()
        Description copied from class: PlanNode
        Computes the hash-code of a plan-node, including any sub-plans of this plan. This method is used to see if two plan nodes (or subtrees) might be equal.
        Specified by:
        hashCode in class PlanNode
        Returns:
        the hash code for the plan node and any subnodes it may contain.