Class BaseTableNumbersVisitor

  • All Implemented Interfaces:
    Visitor

    class BaseTableNumbersVisitor
    extends java.lang.Object
    implements Visitor
    Walk through a subtree and build a list of the assigned numbers for all tables that exist in that subtree. We do this by looking for any column references in the subtree and, for each column reference, we walk down the ColumnReference-ResultColumn chain until we find the the bottom-most table number, which should correspond to a base table.
    • Constructor Summary

      Constructors 
      Constructor Description
      BaseTableNumbersVisitor​(JBitSet tableMap)
      Constructor: takes a JBitSet to use as the holder for any base table numbers found while walking the subtree.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int getColumnNumber()
      Retrieve the the position of the ColumnReference or ResultColumn for which we most recently found a base table number.
      protected void reset()
      Reset the state of this visitor.
      protected void setTableMap​(JBitSet tableMap)
      Set a new JBitSet to serve as the holder for base table numbers we find while walking.
      boolean skipChildren​(Visitable node)
      Method that is called to indicate whether we should skip all nodes below this node for traversal.
      boolean stopTraversal()
      Method that is called to see if query tree traversal should be stopped before visiting all nodes.
      Visitable visit​(Visitable node)
      This is the default visit operation on a QueryTreeNode.
      boolean visitChildrenFirst​(Visitable node)
      Method that is called to see if visit() should be called on the children of node before it is called on node itself.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • tableMap

        private JBitSet tableMap
      • columnNumber

        private int columnNumber
    • Constructor Detail

      • BaseTableNumbersVisitor

        BaseTableNumbersVisitor​(JBitSet tableMap)
        Constructor: takes a JBitSet to use as the holder for any base table numbers found while walking the subtree.
        Parameters:
        tableMap - JBitSet into which we put the table numbers we find.
    • Method Detail

      • setTableMap

        protected void setTableMap​(JBitSet tableMap)
        Set a new JBitSet to serve as the holder for base table numbers we find while walking.
        Parameters:
        tableMap - JBitSet into which we put the table numbers we find.
      • reset

        protected void reset()
        Reset the state of this visitor.
      • getColumnNumber

        protected int getColumnNumber()
        Retrieve the the position of the ColumnReference or ResultColumn for which we most recently found a base table number.
      • visit

        public Visitable visit​(Visitable node)
                        throws StandardException
        Description copied from interface: Visitor
        This is the default visit operation on a QueryTreeNode. It just returns the node. This will typically suffice as the default visit operation for most visitors unless the visitor needs to count the number of nodes visited or something like that.

        Visitors will overload this method by implementing a version with a signature that matches a specific type of node. For example, if I want to do something special with aggregate nodes, then that Visitor will implement a visit(AggregateNode node) method which does the aggregate specific processing.

        Specified by:
        visit in interface Visitor
        Parameters:
        node - the node to process
        Returns:
        a query tree node. Often times this is the same node that was passed in, but Visitors that replace nodes with other nodes will use this to return the new replacement node.
        Throws:
        StandardException - may be throw an error as needed by the visitor (i.e. may be a normal error if a particular node is found, e.g. if checking a group by, we don't expect to find any ColumnReferences that aren't under an AggregateNode -- the easiest thing to do is just throw an error when we find the questionable node).
        See Also:
        Visitor.visit(org.apache.derby.iapi.sql.compile.Visitable)
      • skipChildren

        public boolean skipChildren​(Visitable node)
        Description copied from interface: Visitor
        Method that is called to indicate whether we should skip all nodes below this node for traversal. Useful if we want to effectively ignore/prune all branches under a particular node.

        Differs from stopTraversal() in that it only affects subtrees, rather than the entire traversal.

        Specified by:
        skipChildren in interface Visitor
        Parameters:
        node - the node to process
        Returns:
        true/false
        See Also:
        Visitor.skipChildren(org.apache.derby.iapi.sql.compile.Visitable)
      • stopTraversal

        public boolean stopTraversal()
        Description copied from interface: Visitor
        Method that is called to see if query tree traversal should be stopped before visiting all nodes. Useful for short circuiting traversal if we already know we are done.
        Specified by:
        stopTraversal in interface Visitor
        Returns:
        true/false
        See Also:
        Visitor.stopTraversal()
      • visitChildrenFirst

        public boolean visitChildrenFirst​(Visitable node)
        Description copied from interface: Visitor
        Method that is called to see if visit() should be called on the children of node before it is called on node itself. If this method always returns true, the visitor will walk the tree bottom-up. If it always returns false, the tree is visited top-down.
        Specified by:
        visitChildrenFirst in interface Visitor
        Parameters:
        node - the top node of a sub-tree about to be visited
        Returns:
        true if node's children should be visited before node, false otherwise
        See Also:
        Visitor.visitChildrenFirst(org.apache.derby.iapi.sql.compile.Visitable)