java.lang.Object
org.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
- All Implemented Interfaces:
- org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.Visitable
- public class HalfOuterJoinNode
- extends JoinNode
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.
| Fields inherited from class org.apache.derby.impl.sql.compile.JoinNode |
aggregateVector, CROSSJOIN, flattenableJoin, FULLOUTERJOIN, INNERJOIN, joinClause, joinClauseNormalized, joinPredicates, LEFTOUTERJOIN, RIGHTOUTERJOIN, subqueryList, UNIONJOIN, usingClause |
| 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 |
|
Method Summary |
protected int |
addOuterJoinArguments(ActivationClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
Generate and add any arguments specifict to outer joins. |
protected void |
adjustNumberOfRowsReturned(org.apache.derby.iapi.sql.compile.CostEstimate costEstimate)
Some types of joins (e.g. |
void |
generate(ActivationClassBuilder acb,
org.apache.derby.iapi.services.compiler.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. |
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 determines if (1) the query is a LOJ, and (2) if the LOJ is a candidate for
reordering (i.e., linearization). |
org.apache.derby.iapi.util.JBitSet |
LOJgetNPReferencedTables(int numTables)
|
protected void |
oneRowRightSide(ActivationClassBuilder acb,
org.apache.derby.iapi.services.compiler.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(org.apache.derby.iapi.sql.compile.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 |
accept, bindResultColumns, bindResultColumns, flatten, generateCore, generateCore, getAllResultColumns, getLeftPredicateList, getMatchingColumn, getRightPredicateList, isFlattenableJoinNode, isOrderedOn, joinTypeToString, LOJgetReferencedTables, modifyAccessPath, normExpressions, notFlattenableJoin, optimizeIt, printSubNodes, projectResultColumns, pushExpressionsToLeft, setAggregateVector, setSubqueryList, updateTargetLockMode |
| 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, verifyProperties |
| Methods inherited from class org.apache.derby.impl.sql.compile.FromTable |
areAllColumnsProjected, assignCostEstimate, canBeOrdered, considerSortAvoidancePath, convertAbsoluteToRelativeColumnPosition, cursorTargetTable, estimateCost, feasibleJoinStrategy, fillInReferencedTableMap, forUpdate, getBaseTableName, getBestAccessPath, getBestSortAvoidancePath, getCostEstimate, getCurrentAccessPath, getLevel, getName, getNumColumnsReturned, getProperties, getResultColumnsForList, getSchemaDescriptor, getSchemaDescriptor, getScratchCostEstimate, getTableDescriptor, getTableName, getTableNumber, getTrulyTheBestAccessPath, getUserSpecifiedJoinStrategy, hashKeyColumns, hasTableNumber, init, initAccessPaths, initialCapacity, isBaseTable, isCoveringIndex, isMaterializable, isOneRowScan, isTargetTable, legalJoinOrder, loadFactor, markUpdatableByCursor, maxCapacity, memoryUsageOK, nextAccessPath, optimizeSubqueries, pullOptPredicates, rememberAsBest, rememberJoinStrategyAsBest, rememberSortAvoidancePath, resetJoinStrategies, setAllColumnsProjected, setCostEstimate, setHashKeyColumns, setProperties, setTableNumber, startOptimizing, supportsMultipleInstantiations, tellRowOrderingAboutConstantColumns, uniqueJoin |
| Methods inherited from class org.apache.derby.impl.sql.compile.ResultSetNode |
addNewPredicate, assignResultSetNumber, bindTargetExpressions, bindUntypedNullsToResultColumns, changeAccessPath, closeMethodArgument, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, ensurePredicateList, flattenableInFromSubquery, generateNormalizationResultSet, generateResultSet, genNewRCForInsert, genNormalizeResultSetNode, genProjectRestrict, genProjectRestrict, genProjectRestrictForReordering, getCostEstimate, getCursorTargetTable, getFinalCostEstimate, getFromList, getNewCostEstimate, getOptimizer, getReferencedTableMap, getResultColumns, getResultSetNumber, isNotExists, isOneRowResultSet, isPossibleDistinctScan, isUpdatableCursor, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markStatementResultSet, notCursorTargetTable, numDistinctAggregates, parseDefault, performMaterialization, pushOrderByList, rejectXMLValues, renameGeneratedResultNames, returnsAtMostOneRow, setInsertSource, setReferencedTableMap, setResultColumns, setResultToBooleanTrueNode, setTableConstructorTypes, subqueryReferencesTarget, verifySelectStarSubquery |
| Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist |
rightOuterJoin
private boolean rightOuterJoin
transformed
private boolean transformed
HalfOuterJoinNode
public HalfOuterJoinNode()
init
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 org.apache.derby.iapi.error.StandardException
- Initializer for a HalfOuterJoinNode.
- Overrides:
init in class JoinNode
pushOptPredicate
public boolean pushOptPredicate(org.apache.derby.iapi.sql.compile.OptimizablePredicate optimizablePredicate)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.Optimizable
- Push an OptimizablePredicate down, if this node accepts it.
- Specified by:
pushOptPredicate in interface org.apache.derby.iapi.sql.compile.Optimizable- Overrides:
pushOptPredicate in class JoinNode
toString
public java.lang.String toString()
- Convert this object to a String. See comments in QueryTreeNode.java
for how this should be done for tree printing.
- Overrides:
toString in class TableOperatorNode
preprocess
public ResultSetNode preprocess(int numTables,
GroupByList gbl,
FromList fromList)
throws org.apache.derby.iapi.error.StandardException
- Put a ProjectRestrictNode on top of each FromTable in the FromList.
ColumnReferences must continue to point to the same ResultColumn, so
that ResultColumn must percolate up to the new PRN. However,
that ResultColumn will point to a new expression, a VirtualColumnNode,
which points to the FromTable and the ResultColumn that is the source for
the ColumnReference.
(The new PRN will have the original of the ResultColumnList and
the ResultColumns from that list. The FromTable will get shallow copies
of the ResultColumnList and its ResultColumns. ResultColumn.expression
will remain at the FromTable, with the PRN getting a new
VirtualColumnNode for each ResultColumn.expression.)
We then project out the non-referenced columns. If there are no referenced
columns, then the PRN's ResultColumnList will consist of a single ResultColumn
whose expression is 1.
- Overrides:
preprocess in class JoinNode
pushExpressions
public void pushExpressions(PredicateList outerPredicateList)
throws org.apache.derby.iapi.error.StandardException
- Push expressions down to the first ResultSetNode which can do expression
evaluation and has the same referenced table map.
RESOLVE - This means only pushing down single table expressions to
DistinctNodes today. Once we have a better understanding of how
the optimizer will work, we can push down join clauses.
- Overrides:
pushExpressions in class JoinNode
LOJ_reorderable
public boolean LOJ_reorderable(int numTables)
throws org.apache.derby.iapi.error.StandardException
- This method determines if (1) the query is a LOJ, and (2) if the LOJ is a candidate for
reordering (i.e., linearization). The condition for LOJ linearization is:
1. only LOJ in the fromList, i.e., no INNER, no FULL JOINs, no ROJs
2. ON clause must be equality join between left and right operands and in CNF (i.e., AND is allowed)
- Overrides:
LOJ_reorderable in class JoinNode
LOJ_bindResultColumns
public boolean LOJ_bindResultColumns(boolean anyChange)
throws org.apache.derby.iapi.error.StandardException
transformOuterJoins
public FromTable transformOuterJoins(ValueNode predicateTree,
int numTables)
throws org.apache.derby.iapi.error.StandardException
- Transform any Outer Join into an Inner Join where applicable.
(Based on the existence of a null intolerant
predicate on the inner table.)
- Overrides:
transformOuterJoins in class JoinNode
adjustNumberOfRowsReturned
protected void adjustNumberOfRowsReturned(org.apache.derby.iapi.sql.compile.CostEstimate costEstimate)
- Description copied from class:
JoinNode
- Some types of joins (e.g. outer joins) will return a different
number of rows than is predicted by optimizeIt() in JoinNode.
So, adjust this value now. This method does nothing for most
join types.
- Overrides:
adjustNumberOfRowsReturned in class JoinNode
generate
public void generate(ActivationClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
throws org.apache.derby.iapi.error.StandardException
- Generate the code for an inner join node.
- Overrides:
generate in class JoinNode
addOuterJoinArguments
protected int addOuterJoinArguments(ActivationClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
throws org.apache.derby.iapi.error.StandardException
- Generate and add any arguments specifict to outer joins.
Generate the methods (and add them as parameters) for
returning an empty row from 1 or more sides of an outer join,
if required. Pass whether or not this was originally a
right outer join.
- Overrides:
addOuterJoinArguments in class JoinNode
getNumJoinArguments
protected int getNumJoinArguments()
- Return the number of arguments to the join result set.
- Overrides:
getNumJoinArguments in class JoinNode
oneRowRightSide
protected void oneRowRightSide(ActivationClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
- Overrides:
oneRowRightSide in class JoinNode
getLogicalLeftResultSet
ResultSetNode getLogicalLeftResultSet()
- Return the logical left result set for this qualified
join node.
(For RIGHT OUTER JOIN, the left is the right
and the right is the left and the JOIN is the NIOJ).
- Overrides:
getLogicalLeftResultSet in class JoinNode
getLogicalRightResultSet
ResultSetNode getLogicalRightResultSet()
- Return the logical right result set for this qualified
join node.
(For RIGHT OUTER JOIN, the left is the right
and the right is the left and the JOIN is the NIOJ).
- Overrides:
getLogicalRightResultSet in class JoinNode
isRightOuterJoin
public boolean isRightOuterJoin()
- Return true if right outer join or false if left outer join
Used to set Nullability correctly in JoinNode
LOJgetNPReferencedTables
public org.apache.derby.iapi.util.JBitSet LOJgetNPReferencedTables(int numTables)
throws org.apache.derby.iapi.error.StandardException