|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ResultSetNode
org.apache.derby.impl.sql.compile.FromTable
org.apache.derby.impl.sql.compile.TableOperatorNode
org.apache.derby.impl.sql.compile.JoinNode
A JoinNode represents a join result set for either of the basic DML operations: SELECT and INSERT. For INSERT - SELECT, any of the fields in a JoinNode can be used (the JoinNode represents the (join) SELECT statement in the INSERT - SELECT). For INSERT, the resultColumns in the selectList will contain the names of the columns being inserted into or updated.
Field Summary | |
(package private) java.util.Vector |
aggregateVector
|
static int |
CROSSJOIN
|
protected boolean |
flattenableJoin
|
static int |
FULLOUTERJOIN
|
static int |
INNERJOIN
|
(package private) ValueNode |
joinClause
|
(package private) boolean |
joinClauseNormalized
|
(package private) PredicateList |
joinPredicates
|
static int |
LEFTOUTERJOIN
|
private PredicateList |
leftPredicateList
|
private boolean |
optimized
|
static int |
RIGHTOUTERJOIN
|
private PredicateList |
rightPredicateList
|
(package private) SubqueryList |
subqueryList
|
static int |
UNIONJOIN
|
(package private) ResultColumnList |
usingClause
|
Fields inherited from class org.apache.derby.impl.sql.compile.TableOperatorNode |
leftOptimizer, leftResultSet, nestedInParens, rightOptimizer, rightResultSet |
Fields inherited from class org.apache.derby.impl.sql.compile.FromTable |
bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, loadFactor, maxCapacity, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategy |
Fields inherited from class org.apache.derby.impl.sql.compile.ResultSetNode |
costEstimate, cursorTargetTable, insertSource, optimizer, referencedTableMap, resultColumns, resultSetNumber, scratchCostEstimate, statementResultSet |
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset |
Constructor Summary | |
JoinNode()
|
Method Summary | |
Visitable |
accept(Visitor v)
Accept a visitor, and call v.visit() on child nodes as necessary. |
protected int |
addOuterJoinArguments(ActivationClassBuilder acb,
MethodBuilder mb)
Generate and add any arguments specifict to outer joins. |
protected void |
adjustNumberOfRowsReturned(CostEstimate costEstimate)
Some types of joins (e.g. outer joins) will return a different number of rows than is predicted by optimizeIt() in JoinNode. |
void |
bindResultColumns(FromList fromListParam)
Bind the result columns of this ResultSetNode when there is no base table to bind them to. |
void |
bindResultColumns(TableDescriptor targetTableDescriptor,
FromVTI targetVTI,
ResultColumnList targetColumnList,
DMLStatementNode statement,
FromList fromListParam)
Bind the result columns for this ResultSetNode to a base table. |
private void |
buildRCL()
Build the RCL for this node. |
private void |
deferredBindExpressions(FromList fromListParam)
|
FromList |
flatten(ResultColumnList rcl,
PredicateList outerPList,
SubqueryList sql,
GroupByList gbl)
Flatten this JoinNode into the outer query block. |
void |
generate(ActivationClassBuilder acb,
MethodBuilder mb)
For joins, the tree will be (nodes are left out if the clauses are empty): ProjectRestrictResultSet -- for the having and the select list SortResultSet -- for the group by list ProjectRestrictResultSet -- for the where and the select list (if no group or having) the result set for the fromList |
void |
generateCore(ActivationClassBuilder acb,
MethodBuilder mb,
int joinType)
Generate the code for a qualified join node. |
protected void |
generateCore(ActivationClassBuilder acb,
MethodBuilder mb,
int joinType,
ValueNode joinClause,
SubqueryList subquerys)
Do the generation work for the join node hierarchy. |
ResultColumnList |
getAllResultColumns(java.lang.String allTableName)
Return a ResultColumnList with all of the columns in this table. |
private ResultColumnList |
getAllResultColumnsNoUsing(java.lang.String allTableName)
Return a ResultColumnList with all of the columns in this table. |
private int |
getJoinArguments(ActivationClassBuilder acb,
MethodBuilder mb,
ValueNode joinClause)
Get the arguments to the join result set. |
protected PredicateList |
getLeftPredicateList()
|
(package private) ResultSetNode |
getLogicalLeftResultSet()
Return the logical left result set for this qualified join node. |
(package private) ResultSetNode |
getLogicalRightResultSet()
Return the logical right result set for this qualified join node. |
ResultColumn |
getMatchingColumn(ColumnReference columnReference)
Try to find a ResultColumn in the table represented by this FromTable that matches the name in the given ColumnReference. |
protected int |
getNumJoinArguments()
Return the number of arguments to the join result set. |
protected PredicateList |
getRightPredicateList()
|
private void |
grabJoinPredicates(PredicateList outerPredicateList)
|
void |
init(java.lang.Object leftResult,
java.lang.Object rightResult,
java.lang.Object onClause,
java.lang.Object usingClause,
java.lang.Object selectList,
java.lang.Object tableProperties)
Initializer for a JoinNode. |
boolean |
isFlattenableJoinNode()
Is this FromTable a JoinNode which can be flattened into the parents FromList. |
(package private) boolean |
isOrderedOn(ColumnReference[] crs,
boolean permuteOrdering,
java.util.Vector fbtVector)
Return whether or not the underlying ResultSet tree is ordered on the specified columns. |
static java.lang.String |
joinTypeToString(int joinType)
Convert the joinType to a string. |
boolean |
LOJ_reorderable(int numTables)
Currently we don't reordering any outer join w/ inner joins. |
JBitSet |
LOJgetReferencedTables(int numTables)
|
Optimizable |
modifyAccessPath(JBitSet outerTables)
Modify the access path for this Optimizable, as necessary. |
void |
normExpressions()
Put the expression trees in conjunctive normal form |
(package private) void |
notFlattenableJoin()
Mark this node and its children as not being a flattenable join. |
protected void |
oneRowRightSide(ActivationClassBuilder acb,
MethodBuilder mb)
|
CostEstimate |
optimizeIt(Optimizer optimizer,
OptimizablePredicateList predList,
CostEstimate outerCost,
RowOrdering rowOrdering)
Choose the best access path for this Optimizable. |
ResultSetNode |
preprocess(int numTables,
GroupByList gbl,
FromList fromList)
Put a ProjectRestrictNode on top of each FromTable in the FromList. |
void |
printSubNodes(int depth)
Prints the sub-nodes of this object. |
(package private) void |
projectResultColumns()
Find the unreferenced result columns and project them out. |
void |
pushExpressions(PredicateList outerPredicateList)
Push expressions down to the first ResultSetNode which can do expression evaluation and has the same referenced table map. |
protected void |
pushExpressionsToLeft(PredicateList outerPredicateList)
|
private void |
pushExpressionsToRight(PredicateList outerPredicateList)
|
boolean |
pushOptPredicate(OptimizablePredicate optimizablePredicate)
Push an OptimizablePredicate down, if this node accepts it. |
(package private) void |
setAggregateVector(java.util.Vector aggregateVector)
|
(package private) void |
setSubqueryList(SubqueryList subqueryList)
|
FromTable |
transformOuterJoins(ValueNode predicateTree,
int numTables)
Transform any Outer Join into an Inner Join where applicable. |
int |
updateTargetLockMode()
Get the lock mode for the target of an update statement (a delete or update). |
Methods inherited from class org.apache.derby.impl.sql.compile.TableOperatorNode |
bindExpressions, bindExpressionsWithTables, bindNonVTITables, bindVTITables, decrementLevel, getExposedName, getFromTableByName, getLeftmostResultSet, getLeftResultSet, getNestedInParens, getRightResultSet, init, markOrderingDependent, modifyAccessPaths, needsSpecialRCLBinding, optimize, optimizeSource, referencesSessionSchema, referencesTarget, rejectParameters, replaceDefaults, setLeftmostResultSet, setLevel, setNestedInParens, setReferencedColumns, toString, verifyProperties |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.derby.iapi.sql.compile.Optimizable |
getDataDictionary, getReferencedTableMap, getResultSetNumber |
Field Detail |
public static final int INNERJOIN
public static final int CROSSJOIN
public static final int LEFTOUTERJOIN
public static final int RIGHTOUTERJOIN
public static final int FULLOUTERJOIN
public static final int UNIONJOIN
private boolean optimized
private PredicateList leftPredicateList
private PredicateList rightPredicateList
protected boolean flattenableJoin
java.util.Vector aggregateVector
SubqueryList subqueryList
ValueNode joinClause
boolean joinClauseNormalized
PredicateList joinPredicates
ResultColumnList usingClause
Constructor Detail |
public JoinNode()
Method Detail |
public void init(java.lang.Object leftResult, java.lang.Object rightResult, java.lang.Object onClause, java.lang.Object usingClause, java.lang.Object selectList, java.lang.Object tableProperties) throws StandardException
init
in class QueryTreeNode
leftResult
- The ResultSetNode on the left side of this joinrightResult
- The ResultSetNode on the right side of this joinonClause
- The ON clauseusingClause
- The USING clauseselectList
- The result column list for the jointableProperties
- Properties list associated with the table
StandardException
- Thrown on errorpublic CostEstimate optimizeIt(Optimizer optimizer, OptimizablePredicateList predList, CostEstimate outerCost, RowOrdering rowOrdering) throws StandardException
Optimizable
optimizeIt
in interface Optimizable
optimizeIt
in class FromTable
StandardException
- Thrown on errorOptimizable.optimizeIt(org.apache.derby.iapi.sql.compile.Optimizer, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.CostEstimate, org.apache.derby.iapi.sql.compile.RowOrdering)
public boolean pushOptPredicate(OptimizablePredicate optimizablePredicate) throws StandardException
Optimizable
pushOptPredicate
in interface Optimizable
pushOptPredicate
in class FromTable
StandardException
- Thrown on errorOptimizable.pushOptPredicate(org.apache.derby.iapi.sql.compile.OptimizablePredicate)
public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException
Optimizable
modifyAccessPath
in interface Optimizable
modifyAccessPath
in class TableOperatorNode
StandardException
- Thrown on errorOptimizable.modifyAccessPath(org.apache.derby.iapi.util.JBitSet)
protected void adjustNumberOfRowsReturned(CostEstimate costEstimate)
public ResultColumnList getAllResultColumns(java.lang.String allTableName) throws StandardException
getAllResultColumns
in class ResultSetNode
allTableName
- The qualifier on the "*"
StandardException
- Thrown on errorprivate ResultColumnList getAllResultColumnsNoUsing(java.lang.String allTableName) throws StandardException
allTableName
- The qualifier on the "*"
StandardException
- Thrown on errorpublic ResultColumn getMatchingColumn(ColumnReference columnReference) throws StandardException
getMatchingColumn
in class ResultSetNode
columnReference
- The columnReference whose name we're looking
for in the given table.
StandardException
- Thrown on errorpublic void bindResultColumns(FromList fromListParam) throws StandardException
bindResultColumns
in class TableOperatorNode
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) throws StandardException
bindResultColumns
in class TableOperatorNode
targetTableDescriptor
- The TableDescriptor for the table being
updated or inserted intotargetColumnList
- For INSERT statements, the user
does not have to supply column
names (for example, "insert into t
values (1,2,3)". When this
parameter is null, it means that
the user did not supply column
names, and so the binding should
be done based on order. When it
is not null, it means do the binding
by name, not position.statement
- Calling DMLStatementNode (Insert or Update)fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorprivate void buildRCL() throws StandardException
StandardException
- Thrown on errorprivate void deferredBindExpressions(FromList fromListParam) throws StandardException
StandardException
public ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException
preprocess
in class TableOperatorNode
numTables
- Number of tables in the DML Statementgbl
- The group by list, if anyfromList
- The from list, if any
StandardException
- Thrown on errorvoid projectResultColumns() throws StandardException
projectResultColumns
in class TableOperatorNode
StandardException
public void normExpressions() throws StandardException
StandardException
- Thrown on errorpublic void pushExpressions(PredicateList outerPredicateList) throws StandardException
pushExpressions
in class FromTable
outerPredicateList
- The PredicateList from the outer RS.
StandardException
- Thrown on errorprotected void pushExpressionsToLeft(PredicateList outerPredicateList) throws StandardException
StandardException
private void pushExpressionsToRight(PredicateList outerPredicateList) throws StandardException
StandardException
private void grabJoinPredicates(PredicateList outerPredicateList) throws StandardException
StandardException
public FromList flatten(ResultColumnList rcl, PredicateList outerPList, SubqueryList sql, GroupByList gbl) throws StandardException
flatten
in class FromTable
rcl
- The RCL from the outer queryouterPList
- PredicateList to append wherePredicates to.sql
- The SubqueryList from the outer querygbl
- The group by list, if any
StandardException
- Thrown on errorpublic boolean LOJ_reorderable(int numTables) throws StandardException
LOJ_reorderable
in class FromTable
StandardException
public FromTable transformOuterJoins(ValueNode predicateTree, int numTables) throws StandardException
transformOuterJoins
in class FromTable
predicateTree
- The predicate tree for the query block
StandardException
- Thrown on errorpublic void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
generate
in class QueryTreeNode
acb
- The ActivationClassBuilder for the class being builtmb
- The method for the generated code to go into
StandardException
- Thrown on errorpublic void generateCore(ActivationClassBuilder acb, MethodBuilder mb, int joinType) throws StandardException
StandardException
- Thrown on errorprotected void generateCore(ActivationClassBuilder acb, MethodBuilder mb, int joinType, ValueNode joinClause, SubqueryList subquerys) throws StandardException
acb
- The ActivationClassBuildermb
- the method the code is to go intojoinType
- The join typejoinClause
- The join clause, if anysubquerys
- The list of subqueries in the join clause, if any
StandardException
- Thrown on errorprivate int getJoinArguments(ActivationClassBuilder acb, MethodBuilder mb, ValueNode joinClause) throws StandardException
acb
- The ActivationClassBuilder for the class we're building.mb
- the method the generated code is going intojoinClause
- The join clause, if any
StandardException
- Thrown on errorprotected void oneRowRightSide(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
StandardException
protected int getNumJoinArguments()
protected int addOuterJoinArguments(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
acb
- The ActivationClassBuildermb
- the method the generated code is to go into
return The number of args added
StandardException
- Thrown on errorpublic static java.lang.String joinTypeToString(int joinType)
protected PredicateList getLeftPredicateList() throws StandardException
StandardException
protected PredicateList getRightPredicateList() throws StandardException
StandardException
public int updateTargetLockMode()
updateTargetLockMode
in class ResultSetNode
TransactionController
void notFlattenableJoin()
notFlattenableJoin
in class ResultSetNode
public boolean isFlattenableJoinNode()
isFlattenableJoinNode
in class FromTable
boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, java.util.Vector fbtVector) throws StandardException
isOrderedOn
in class ResultSetNode
crs
- The specified ColumnReference[]permuteOrdering
- Whether or not the order of the CRs in the array can be permutedfbtVector
- Vector that is to be filled with the FromBaseTable
StandardException
- Thrown on errorpublic void printSubNodes(int depth)
printSubNodes
in class TableOperatorNode
depth
- The depth of this node in the tree
void setSubqueryList(SubqueryList subqueryList)
void setAggregateVector(java.util.Vector aggregateVector)
ResultSetNode getLogicalLeftResultSet()
ResultSetNode getLogicalRightResultSet()
public Visitable accept(Visitor v) throws StandardException
accept
in interface Visitable
accept
in class TableOperatorNode
v
- the visitor
StandardException
- on errorpublic JBitSet LOJgetReferencedTables(int numTables) throws StandardException
LOJgetReferencedTables
in class ResultSetNode
StandardException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |