Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class BaseTableNumbersVisitor

extends Object
implements Visitor
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.sql.compile.Visitor
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.sql.compile.Visitable, .Visitor, org.apache.derby.iapi.util.JBitSet

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.

Field Summary

Modifier and TypeField and Description
private int
private JBitSet

Constructor Summary

AccessConstructor and Description
pack-priv
BaseTableNumbersVisitor(JBitSet
JBitSet into which we put the table numbers we find.
tableMap
)

Constructor: takes a JBitSet to use as the holder for any base table numbers found while walking the subtree.

Method Summary

Modifier and TypeMethod and 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
JBitSet into which we put the table numbers we find.
tableMap
)

Set a new JBitSet to serve as the holder for base table numbers we find while walking.

public boolean
skipChildren(Visitable
the node to process
node
)

Implements org.apache.derby.iapi.sql.compile.Visitor.skipChildren.

Method that is called to indicate whether we should skip all nodes below this node for traversal.

public boolean
stopTraversal()

Implements org.apache.derby.iapi.sql.compile.Visitor.stopTraversal.

Method that is called to see if query tree traversal should be stopped before visiting all nodes.

public Visitable
visit(Visitable
the node to process
node
)

Implements org.apache.derby.iapi.sql.compile.Visitor.visit.

This is the default visit operation on a QueryTreeNode.

public boolean
visitChildrenFirst(Visitable
the top node of a sub-tree about to be visited
node
)

Implements org.apache.derby.iapi.sql.compile.Visitor.visitChildrenFirst.

Method that is called to see if visit() should be called on the children of node before it is called on node itself.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

columnNumberback to summary
private int columnNumber
tableMapback to summary
private JBitSet tableMap

Constructor Detail

BaseTableNumbersVisitorback to summary
pack-priv 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

JBitSet into which we put the table numbers we find.

Method Detail

getColumnNumberback to summary
protected int getColumnNumber()

Retrieve the the position of the ColumnReference or ResultColumn for which we most recently found a base table number.

resetback to summary
protected void reset()

Reset the state of this visitor.

setTableMapback to summary
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

JBitSet into which we put the table numbers we find.

skipChildrenback to summary
public boolean skipChildren(Visitable node)

Implements org.apache.derby.iapi.sql.compile.Visitor.skipChildren.

Doc from org.apache.derby.iapi.sql.compile.Visitor.skipChildren.

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.

Parameters
node:Visitable

the node to process

Returns:boolean

true/false

See Also
org.apache.derby.iapi.sql.compile.Visitor#skipChildren
stopTraversalback to summary
public boolean stopTraversal()

Implements org.apache.derby.iapi.sql.compile.Visitor.stopTraversal.

Doc from org.apache.derby.iapi.sql.compile.Visitor.stopTraversal.

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.

Returns:boolean

true/false

See Also
org.apache.derby.iapi.sql.compile.Visitor#stopTraversal
visitback to summary
public Visitable visit(Visitable node) throws StandardException

Implements org.apache.derby.iapi.sql.compile.Visitor.visit.

Doc from org.apache.derby.iapi.sql.compile.Visitor.visit.

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.

Parameters
node:Visitable

the node to process

Returns:Visitable

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.

Exceptions
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
org.apache.derby.iapi.sql.compile.Visitor#visit
visitChildrenFirstback to summary
public boolean visitChildrenFirst(Visitable node)

Implements org.apache.derby.iapi.sql.compile.Visitor.visitChildrenFirst.

Doc from org.apache.derby.iapi.sql.compile.Visitor.visitChildrenFirst.

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.

Parameters
node:Visitable

the top node of a sub-tree about to be visited

Returns:boolean

true if node's children should be visited before node, false otherwise

See Also
org.apache.derby.iapi.sql.compile.Visitor#visitChildrenFirst