Class FileScanNode

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class FileScanNode
    extends SelectNode

    A select plan-node that scans a tuple file, checking the optional predicate against each tuple in the file. Note that there are no optimizations used if the tuple file is a sequential tuple file or a hashed tuple file.

    This plan node can also be used with indexes, when a "file-scan" is to be performed over all of the index's tuples, in whatever order the index will produce the tuples. If the planner wishes to take advantage of an index's ability to look up tuples based on various values, the IndexScanNode should be used instead.

    • Field Detail

      • logger

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

        private TableInfo tableInfo
        The table-info for the table being scanned, or null if the node is performing a scan over an index.
      • indexInfo

        private IndexInfo indexInfo
        The index-info for the index being scanned, or null if the node is performing a scan over a table.
      • tupleFile

        private TupleFile tupleFile
        The table to select from if this node is a leaf.
      • markedTuple

        private FilePointer markedTuple
        This field allows the file-scan node to mark a particular tuple in the tuple-stream and then rewind to that point in the tuple-stream.
      • jumpToMarkedTuple

        private boolean jumpToMarkedTuple
    • Constructor Detail

      • FileScanNode

        public FileScanNode​(TableInfo tableInfo,
                            Expression predicate)
        Construct a file scan node that traverses a table file.
        Parameters:
        tableInfo - the information about the table being scanned
        predicate - an optional predicate for selection, or null if all rows in the table should be included in the output
      • FileScanNode

        public FileScanNode​(IndexInfo indexInfo,
                            Expression predicate)
        Construct a file scan node that traverses an index file.
        Parameters:
        indexInfo - the information about the index being scanned
        predicate - an optional predicate for selection, or null if all rows in the index should be included in the output
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Returns true if the passed-in object is a FileScanNode with the same predicate and table.
        Specified by:
        equals in class PlanNode
        Parameters:
        obj - the object to check for equality
        Returns:
        true if the passed-in object is equal to this object; false otherwise
      • hashCode

        public int hashCode()
        Computes the hashcode of a PlanNode. This method is used to see if two plan nodes CAN be equal.
        Specified by:
        hashCode in class PlanNode
        Returns:
        the hash code for the plan node and any subnodes it may contain.
      • clone

        protected PlanNode clone()
                          throws java.lang.CloneNotSupportedException
        Creates a copy of this simple filter node node and its subtree. This method is used by PlanNode.duplicate() to copy a plan tree.
        Overrides:
        clone in class SelectNode
        Throws:
        java.lang.CloneNotSupportedException
      • 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.
      • resultsOrderedBy

        public java.util.List<OrderByExpression> resultsOrderedBy()
        Currently we will always say that the file-scan node produces unsorted results. In actuality, a file scan's results will be sorted if the table file uses a sequential format, but currently we don't have any sequential file formats.
        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()
        This node supports marking.
        Overrides:
        supportsMarking in class PlanNode
        Returns:
        true if the node supports position marking, false otherwise.
      • requiresLeftMarking

        public boolean requiresLeftMarking()
        This node has no children so of course it doesn't require marking.
        Overrides:
        requiresLeftMarking in class PlanNode
        Returns:
        true if the node requires that its left child supports marking, false otherwise.
      • requiresRightMarking

        public boolean requiresRightMarking()
        This node has no children so of course it doesn't require marking.
        Overrides:
        requiresRightMarking in class PlanNode
        Returns:
        true if the node requires that its right child supports marking, false otherwise.
      • prepareSchema

        protected void prepareSchema()
      • 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: SelectNode
        Do initialization for the select operation. Resets state variables.
        Overrides:
        initialize in class SelectNode
      • 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
      • advanceCurrentTuple

        protected void advanceCurrentTuple()
        Advances the current tuple forward for a file scan. Grabs the first tuple if current is null. Otherwise gets the next tuple.
        Specified by:
        advanceCurrentTuple in class SelectNode
      • 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