Class SelectNode

  • All Implemented Interfaces:
    java.lang.Cloneable
    Direct Known Subclasses:
    FileScanNode, SimpleFilterNode

    public abstract class SelectNode
    extends PlanNode
    PlanNode representing the WHERE clause in a SELECT operation. This is the relational algebra Select operator.
    • Field Detail

      • predicate

        public Expression predicate
        Predicate used for selection.
      • currentTuple

        protected Tuple currentTuple
        The current tuple that the node is selecting.
      • done

        private boolean done
        True if we have finished scanning or pulling tuples from children.
    • Constructor Detail

      • SelectNode

        protected SelectNode​(Expression predicate)
        Constructs a SelectNode that scans a file for tuples.
        Parameters:
        predicate - the selection criterion
    • Method Detail

      • clone

        protected PlanNode clone()
                          throws java.lang.CloneNotSupportedException
        Creates a copy of this select node and its subtree. This method is used by PlanNode.duplicate() to copy a plan tree.
        Overrides:
        clone in class PlanNode
        Throws:
        java.lang.CloneNotSupportedException
      • initialize

        public void initialize()
        Do initialization for the select operation. Resets state variables.
        Overrides:
        initialize in class PlanNode
      • getNextTuple

        public Tuple getNextTuple()
        Gets the next tuple selected by the predicate.
        Specified by:
        getNextTuple in class PlanNode
        Returns:
        the tuple to be passed up to the next node.
        Throws:
        java.lang.IllegalStateException - if this is a scanning node with no algorithm or a filtering node with no child, or if the leftChild threw an IllegalStateException.
      • advanceCurrentTuple

        protected abstract void advanceCurrentTuple()
        Helper function that advances the current tuple reference in the node.
      • isTupleSelected

        protected boolean isTupleSelected​(Tuple tuple)