|
|||||||||
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
org.apache.derby.impl.sql.compile.HalfOuterJoinNode
public class HalfOuterJoinNode
An HalfOuterJoinNode represents a left or a right outer join result set. Right outer joins are always transformed into left outer joins during preprocessing for simplicity.
Field Summary | |
---|---|
private boolean |
rightOuterJoin
|
private boolean |
transformed
|
Fields inherited from class org.apache.derby.impl.sql.compile.JoinNode |
---|
aggregateVector, CROSSJOIN, flattenableJoin, FULLOUTERJOIN, INNERJOIN, joinClause, joinClauseNormalized, joinOrderStrategyProperties, joinPredicates, LEFTOUTERJOIN, RIGHTOUTERJOIN, subqueryList, UNIONJOIN, usingClause |
Fields inherited from class org.apache.derby.impl.sql.compile.TableOperatorNode |
---|
leftOptimizer, leftResultSet, rightOptimizer, rightResultSet |
Fields inherited from class org.apache.derby.impl.sql.compile.FromTable |
---|
ADD_PLAN, bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, LOAD_PLAN, loadFactor, maxCapacity, origTableName, REMOVE_PLAN, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategy |
Fields inherited from class org.apache.derby.impl.sql.compile.ResultSetNode |
---|
costEstimate, cursorTargetTable, finalCostEstimate, insertSource, optimizer, referencedTableMap, resultColumns, resultSetNumber, scratchCostEstimate, statementResultSet |
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
---|
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired |
Constructor Summary | |
---|---|
HalfOuterJoinNode()
|
Method Summary | |
---|---|
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 |
generate(ActivationClassBuilder acb,
MethodBuilder mb)
Generate the code for an inner join node. |
(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. |
protected int |
getNumJoinArguments()
Return the number of arguments to the join result set. |
void |
init(java.lang.Object leftResult,
java.lang.Object rightResult,
java.lang.Object onClause,
java.lang.Object usingClause,
java.lang.Object rightOuterJoin,
java.lang.Object tableProperties)
Initializer for a HalfOuterJoinNode. |
private boolean |
isNullRejecting(ValueNode joinClause,
JBitSet leftTableMap,
JBitSet rightTableMap)
Tests pRiRj in the sense of Galindo-Legaria et al: Outerjoin Simplification and Reordering for Query Optimization, ACM Transactions on Database Systems, Vol. 22, No. 1, March 1997, Pages 43-74: "The set of attributes referenced by a predicate p is called the schema of p, and denoted sch(p). |
boolean |
isRightOuterJoin()
Return true if right outer join or false if left outer join Used to set Nullability correctly in JoinNode |
boolean |
LOJ_bindResultColumns(boolean anyChange)
|
boolean |
LOJ_reorderable(int numTables)
This method recursively: determines if this part of the query tree is a compound OJ of the shape required for reordering and if so, does a reordering. |
JBitSet |
LOJgetNPReferencedTables(int numTables)
|
JBitSet |
LOJgetRPReferencedTables(int numTables)
|
protected void |
oneRowRightSide(ActivationClassBuilder acb,
MethodBuilder mb)
|
ResultSetNode |
preprocess(int numTables,
GroupByList gbl,
FromList fromList)
Put a ProjectRestrictNode on top of each FromTable in the FromList. |
void |
pushExpressions(PredicateList outerPredicateList)
Push expressions down to the first ResultSetNode which can do expression evaluation and has the same referenced table map. |
boolean |
pushOptPredicate(OptimizablePredicate optimizablePredicate)
Push an OptimizablePredicate down, if this node accepts it. |
java.lang.String |
toString()
Convert this object to a String. |
FromTable |
transformOuterJoins(ValueNode predicateTree,
int numTables)
Transform any Outer Join into an Inner Join where applicable. |
Methods inherited from class org.apache.derby.impl.sql.compile.JoinNode |
---|
acceptChildren, bindExpressions, bindResultColumns, bindResultColumns, flatten, generateCore, generateCore, getAllResultColumns, getFinalCostEstimate, getLeftPredicateList, getMatchingColumn, getRightPredicateList, init, isFlattenableJoinNode, isOrderedOn, joinTypeToString, LOJgetReferencedTables, modifyAccessPath, normExpressions, notFlattenableJoin, optimizeIt, printSubNodes, projectResultColumns, pushExpressionsToLeft, setAggregateVector, setNaturalJoin, setSubqueryList, updateTargetLockMode |
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 |
---|
private boolean rightOuterJoin
private boolean transformed
Constructor Detail |
---|
public HalfOuterJoinNode()
Method Detail |
---|
public void init(java.lang.Object leftResult, java.lang.Object rightResult, java.lang.Object onClause, java.lang.Object usingClause, java.lang.Object rightOuterJoin, 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 clauserightOuterJoin
- Whether or not this node represents a user
specified right outer jointableProperties
- Properties list associated with the table
StandardException
- Thrown on errorpublic boolean pushOptPredicate(OptimizablePredicate optimizablePredicate) throws StandardException
Optimizable
pushOptPredicate
in interface Optimizable
pushOptPredicate
in class JoinNode
optimizablePredicate
- OptimizablePredicate to push down.
StandardException
- Thrown on errorOptimizable.pushOptPredicate(org.apache.derby.iapi.sql.compile.OptimizablePredicate)
public java.lang.String toString()
toString
in class TableOperatorNode
public ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException
preprocess
in class JoinNode
numTables
- Number of tables in the DML Statementgbl
- The group by list, if anyfromList
- The from list, if any
StandardException
- Thrown on errorpublic void pushExpressions(PredicateList outerPredicateList) throws StandardException
pushExpressions
in class JoinNode
outerPredicateList
- The PredicateList from the outer RS.
StandardException
- Thrown on errorpublic boolean LOJ_reorderable(int numTables) throws StandardException
OJ1 pT1T2 OJ1 pT2T3 / \ / \ / \ can / t3 t1 OJ2 pT2T3 reorder / / \ to OJ2 pT1T2 / \ / \ t2 t3 / \ t1 t2 where pR1R2 is a null-rejecting predicate which references the schema of joinee R1 and R2, cf. terminology explanation in #isNullRejecting. OJ1 represents this before and after the reordering.The join predicates are assumed to be in CNF form. Note: Present implementation limitations
LOJ_reorderable
in class JoinNode
numTables
- number of tables involved (needed to right size the
bitmaps)
StandardException
- standard error policyprivate boolean isNullRejecting(ValueNode joinClause, JBitSet leftTableMap, JBitSet rightTableMap) throws StandardException
"The set of attributes referenced by a predicate p is called the schema of p, and denoted sch(p). As a notational convention, we annotate predicates to reflect their schema. If sch(p) includes attributes of both Ri, Rj and only those relations, we can write the predicate as pRiRj.If a null-valued column is compared in a predicate that contains no OR connectives, the predicate evaluates to undefined, and the tuple is rejected. The relops satisfy this criterion. To simplify analysis, we only accept predicates of the form:
X relop Y [and .. and X-n relop Y-n]At least one of the relops should reference both
leftTableMap
and rightTableMap
, so that we know that sch(p) includes
attributes of both Ri, Rj. I.e.
X
should be a table in leftTableMap
, and
Y
should be a table in rightTableMap
.
or
X
should be a table in rightTableMap
, and
Y
should be a table in leftTableMap
.
joinClause
- The join clause (i.e. predicate) we want to checkleftTableMap
- a bit map representing the tables expected for the
predicate (logical left)rightTableMap
- a bit map representing the tables expected for the
predicate (logical right)
joinClause
has at least one relop that
references both leftTableMap
and rightTableMap
StandardException
- standard exception policypublic boolean LOJ_bindResultColumns(boolean anyChange) throws StandardException
StandardException
public FromTable transformOuterJoins(ValueNode predicateTree, int numTables) throws StandardException
transformOuterJoins
in class JoinNode
predicateTree
- The predicate tree for the query block
StandardException
- Thrown on errorprotected void adjustNumberOfRowsReturned(CostEstimate costEstimate)
JoinNode
adjustNumberOfRowsReturned
in class JoinNode
JoinNode.adjustNumberOfRowsReturned(org.apache.derby.iapi.sql.compile.CostEstimate)
public void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
generate
in class JoinNode
acb
- The ActivationClassBuilder for the class being builtmb
- The method for the generated code to go into
StandardException
- Thrown on errorprotected int addOuterJoinArguments(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
addOuterJoinArguments
in class JoinNode
acb
- The ActivationClassBuildermb
- the method the generate code is to go into
return The args that have been added
StandardException
- Thrown on errorprotected int getNumJoinArguments()
getNumJoinArguments
in class JoinNode
protected void oneRowRightSide(ActivationClassBuilder acb, MethodBuilder mb)
oneRowRightSide
in class JoinNode
ResultSetNode getLogicalLeftResultSet()
getLogicalLeftResultSet
in class JoinNode
ResultSetNode getLogicalRightResultSet()
getLogicalRightResultSet
in class JoinNode
public boolean isRightOuterJoin()
public JBitSet LOJgetNPReferencedTables(int numTables) throws StandardException
StandardException
public JBitSet LOJgetRPReferencedTables(int numTables) throws StandardException
StandardException
|
Built on Thu 2010-12-23 20:49:13+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |