|
||||||||||
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.SingleChildResultSetNode
org.apache.derby.impl.sql.compile.ProjectRestrictNode
A ProjectRestrictNode represents a result set for any of the basic DML operations: SELECT, INSERT, UPDATE, and DELETE. For INSERT with a VALUES clause, restriction will be null. For both INSERT and UPDATE, the resultColumns in the selectList will contain the names of the columns being inserted into or updated. NOTE: A ProjectRestrictNode extends FromTable since it can exist in a FromList.
Field Summary | |
private boolean |
accessPathConsidered
|
private boolean |
accessPathModified
|
(package private) ResultSetNode |
childResult
ResultSetNode under the SingleChildResultSetNode |
private boolean |
childResultOptimized
|
(package private) ValueNode |
constantRestriction
Constant expressions to be evaluated here. |
private boolean |
getTableNumberHere
|
protected boolean |
hasTrulyTheBestAccessPath
|
private boolean |
materialize
|
(package private) SubqueryList |
projectSubquerys
List of subqueries in projection |
ValueNode |
restriction
The ValueNode for the restriction to be evaluated here. |
PredicateList |
restrictionList
Restriction as a PredicateList |
(package private) SubqueryList |
restrictSubquerys
List of subqueries in restriction |
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 | |
ProjectRestrictNode()
|
Method Summary | |
Visitable |
accept(Visitor v)
Accept a visitor, and call v.visit() on child nodes as necessary. |
ResultSetNode |
addNewPredicate(Predicate predicate)
Add a new predicate to the list. |
ResultSetNode |
changeAccessPath()
The optimizer's decision on the access path for a result set may require the generation of extra result sets. |
ResultSetNode |
considerMaterialization(JBitSet outerTables)
Consider materialization for this ResultSet tree if it is valid and cost effective (It is not valid if incorrect results would be returned.) |
boolean |
considerSortAvoidancePath()
Check whether this optimizable's sort avoidance path should be considered. |
(package private) void |
decrementLevel(int decrement)
Decrement (query block) level (0-based) for this FromTable. |
ResultSetNode |
ensurePredicateList(int numTables)
Ensure that the top of the RSN tree has a PredicateList. |
boolean |
feasibleJoinStrategy(OptimizablePredicateList predList,
Optimizer optimizer)
Is the current proposed join strategy for this optimizable feasible given the predicate list? |
boolean |
flattenableInFromSubquery(FromList fromList)
Evaluate whether or not the subquery in a FromSubquery is flattenable. |
boolean |
forUpdate()
Return true if this is the target table of an update |
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 |
private void |
generateMinion(ExpressionClassBuilder acb,
MethodBuilder mb,
boolean genChildResultSet)
Logic shared by generate() and generateResultSet(). |
void |
generateNOPProjectRestrict()
Bypass the generation of this No-Op ProjectRestrict, and just generate its child result set. |
void |
generateResultSet(ExpressionClassBuilder acb,
MethodBuilder mb)
General logic shared by Core compilation. |
AccessPath |
getBestAccessPath()
Get the best access path for this Optimizable. |
AccessPath |
getBestSortAvoidancePath()
Get the best sort-avoidance path for this Optimizable. |
ResultSetNode |
getChildResult()
Return the childResult from this node. |
CostEstimate |
getCostEstimate()
Get the CostEstimate for this ProjectRestrictNode. |
AccessPath |
getCurrentAccessPath()
Get the current access path under consideration for this Optimizable |
CostEstimate |
getFinalCostEstimate()
Get the final CostEstimate for this ProjectRestrictNode. |
protected FromTable |
getFromTableByName(java.lang.String name,
java.lang.String schemaName,
boolean exactMatch)
Determine whether or not the specified name is an exposed name in the current query block. |
(package private) PredicateList |
getRestrictionList()
Return the restriction list from this node. |
int |
getTableNumber()
Get this Optimizable's table number |
AccessPath |
getTrulyTheBestAccessPath()
Get the best access path overall for this Optimizable. |
(package private) java.lang.String |
getUserSpecifiedJoinStrategy()
Return the user specified join strategy, if any for this table. |
void |
init(java.lang.Object childResult,
java.lang.Object tableProperties)
Initialilzer for a SingleChildResultSetNode. |
void |
init(java.lang.Object childResult,
java.lang.Object projection,
java.lang.Object restriction,
java.lang.Object restrictionList,
java.lang.Object projectSubquerys,
java.lang.Object restrictSubquerys,
java.lang.Object tableProperties)
Initializer for a ProjectRestrictNode. |
void |
initAccessPaths(Optimizer optimizer)
Init the access paths for this optimizable. |
boolean |
isMaterializable()
Tell whether this Optimizable is materializable |
boolean |
isNotExists()
Return whether or not the underlying ResultSet tree is for a NOT EXISTS join. |
boolean |
isOneRowResultSet()
Return whether or not the underlying ResultSet tree will return a single row, at most. |
(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. |
(package private) boolean |
isPossibleDistinctScan()
Is it possible to do a distinct scan on this ResultSet tree. |
boolean |
legalJoinOrder(JBitSet assignedTableMap)
Can this Optimizable appear at the current location in the join order. |
(package private) void |
markForDistinctScan()
Mark the underlying scan as a distinct scan. |
(package private) void |
markOrderingDependent()
Notify the underlying result set tree that the result is ordering dependent. |
Optimizable |
modifyAccessPath(JBitSet outerTables)
Modify the access path for this Optimizable, as necessary. |
ResultSetNode |
modifyAccessPaths()
Modify the access paths according to the decisions the optimizer made. |
boolean |
nextAccessPath(Optimizer optimizer,
OptimizablePredicateList predList,
RowOrdering rowOrdering)
Choose the next access path to evaluate for this Optimizable. |
(package private) boolean |
nopProjectRestrict()
Determine whether this ProjectRestrict does anything. |
ResultSetNode |
optimize(DataDictionary dataDictionary,
PredicateList predicates,
double outerRows)
Optimize this ProjectRestrictNode. |
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. |
(package private) void |
printRememberingBestAccessPath(int planType,
AccessPath bestPath)
|
void |
printSubNodes(int depth)
Prints the sub-nodes of this object. |
void |
pullOptPredicates(OptimizablePredicateList optimizablePredicates)
Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList. |
void |
pushExpressions(PredicateList predicateList)
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. |
boolean |
referencesSessionSchema()
Return true if the node references SESSION schema tables (temporary or permanent) |
boolean |
referencesTarget(java.lang.String name,
boolean baseTable)
Search to see if a query references the specifed table name. |
protected boolean |
reflectionNeededForProjection()
Determine whether we need to do reflection in order to do the projection. |
void |
rememberAsBest(int planType)
Remember the current access path as the best one (so far). |
void |
rememberSortAvoidancePath()
Mark this optimizable so that its sort avoidance path will be considered. |
(package private) void |
replaceDefaults(TableDescriptor ttd,
ResultColumnList tcl)
Replace any DEFAULTs with the associated tree for the default. |
private Optimizable |
replaceWithHashTableNode()
This method creates a HashTableNode between the PRN and it's child when the optimizer chooses hash join on an arbitrary (non-FBT) result set tree. |
(package private) void |
setChildResult(ResultSetNode childResult)
Set the childResult for this node. |
void |
setLevel(int level)
Set the (query block) level (0-based) for this FromTable. |
void |
setRefActionInfo(long fkIndexConglomId,
int[] fkColArray,
java.lang.String parentResultSetId,
boolean dependentScan)
set the Information gathered from the parent table that is required to peform a referential action on dependent table. |
void |
startOptimizing(Optimizer optimizer,
RowOrdering rowOrdering)
Begin the optimization process for this Optimizable. |
(package private) boolean |
subqueryReferencesTarget(java.lang.String name,
boolean baseTable)
Return whether or not this ResultSetNode contains a subquery with a reference to the specified target. |
double |
uniqueJoin(OptimizablePredicateList predList)
Does this optimizable have a uniqueness condition on the given predicate list, and if so, how many unique keys will be returned per scan. |
int |
updateTargetLockMode()
Get the lock mode for the target of an update statement (a delete or update). |
void |
verifyProperties(DataDictionary dDictionary)
Verify that the Properties list with optimizer overrides, if specified, is valid |
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 ValueNode restriction
ValueNode constantRestriction
public PredicateList restrictionList
SubqueryList projectSubquerys
SubqueryList restrictSubquerys
private boolean accessPathModified
private boolean accessPathConsidered
private boolean childResultOptimized
private boolean materialize
private boolean getTableNumberHere
ResultSetNode childResult
protected boolean hasTrulyTheBestAccessPath
Constructor Detail |
public ProjectRestrictNode()
Method Detail |
public void init(java.lang.Object childResult, java.lang.Object projection, java.lang.Object restriction, java.lang.Object restrictionList, java.lang.Object projectSubquerys, java.lang.Object restrictSubquerys, java.lang.Object tableProperties)
init
in class QueryTreeNode
childResult
- The child ResultSetNodeprojection
- The result column list for the projectionrestriction
- An expression representing the restriction to be
evaluated here.restrictionList
- Restriction as a PredicateListprojectSubquerys
- List of subqueries in the projectionrestrictSubquerys
- List of subqueries in the restrictiontableProperties
- Properties list associated with the tablepublic boolean nextAccessPath(Optimizer optimizer, OptimizablePredicateList predList, RowOrdering rowOrdering) throws StandardException
Optimizable
nextAccessPath
in interface Optimizable
nextAccessPath
in class FromTable
StandardException
- Thrown on errorOptimizable.nextAccessPath(org.apache.derby.iapi.sql.compile.Optimizer, org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.RowOrdering)
public void rememberAsBest(int planType) throws StandardException
Optimizable
rememberAsBest
in interface Optimizable
rememberAsBest
in class FromTable
StandardException
- Thrown on errorOptimizable.rememberAsBest(int)
void printRememberingBestAccessPath(int planType, AccessPath bestPath)
public void startOptimizing(Optimizer optimizer, RowOrdering rowOrdering)
Optimizable
startOptimizing
in interface Optimizable
startOptimizing
in class FromTable
Optimizable.startOptimizing(org.apache.derby.iapi.sql.compile.Optimizer, org.apache.derby.iapi.sql.compile.RowOrdering)
public int getTableNumber()
Optimizable
getTableNumber
in interface Optimizable
getTableNumber
in class FromTable
Optimizable.getTableNumber()
public 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 feasibleJoinStrategy(OptimizablePredicateList predList, Optimizer optimizer) throws StandardException
Optimizable
feasibleJoinStrategy
in interface Optimizable
feasibleJoinStrategy
in class FromTable
StandardException
- Thrown on errorOptimizable.feasibleJoinStrategy(org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.compile.Optimizer)
public AccessPath getCurrentAccessPath()
Optimizable
getCurrentAccessPath
in interface Optimizable
getCurrentAccessPath
in class FromTable
Optimizable.getCurrentAccessPath()
public AccessPath getBestAccessPath()
Optimizable
getBestAccessPath
in interface Optimizable
getBestAccessPath
in class FromTable
Optimizable.getBestAccessPath()
public AccessPath getBestSortAvoidancePath()
Optimizable
getBestSortAvoidancePath
in interface Optimizable
getBestSortAvoidancePath
in class FromTable
Optimizable.getBestSortAvoidancePath()
public AccessPath getTrulyTheBestAccessPath()
Optimizable
getTrulyTheBestAccessPath
in interface Optimizable
getTrulyTheBestAccessPath
in class SingleChildResultSetNode
Optimizable.getTrulyTheBestAccessPath()
public void rememberSortAvoidancePath()
Optimizable
rememberSortAvoidancePath
in interface Optimizable
rememberSortAvoidancePath
in class FromTable
Optimizable.rememberSortAvoidancePath()
public boolean considerSortAvoidancePath()
Optimizable
considerSortAvoidancePath
in interface Optimizable
considerSortAvoidancePath
in class FromTable
Optimizable.considerSortAvoidancePath()
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 void pullOptPredicates(OptimizablePredicateList optimizablePredicates) throws StandardException
Optimizable
pullOptPredicates
in interface Optimizable
pullOptPredicates
in class SingleChildResultSetNode
StandardException
- Thrown on errorOptimizable.pullOptPredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList)
public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException
Optimizable
modifyAccessPath
in interface Optimizable
modifyAccessPath
in class FromTable
StandardException
- Thrown on errorOptimizable.modifyAccessPath(org.apache.derby.iapi.util.JBitSet)
private Optimizable replaceWithHashTableNode() throws StandardException
StandardException
- Thrown on errorpublic void verifyProperties(DataDictionary dDictionary) throws StandardException
Optimizable
verifyProperties
in interface Optimizable
verifyProperties
in class FromTable
StandardException
- Thrown on errorOptimizable.verifyProperties(org.apache.derby.iapi.sql.dictionary.DataDictionary)
public boolean legalJoinOrder(JBitSet assignedTableMap)
Optimizable
legalJoinOrder
in interface Optimizable
legalJoinOrder
in class FromTable
Optimizable.legalJoinOrder(org.apache.derby.iapi.util.JBitSet)
public boolean isMaterializable() throws StandardException
Optimizable
isMaterializable
in interface Optimizable
isMaterializable
in class FromTable
StandardException
- Thrown on errorOptimizable.isMaterializable()
public double uniqueJoin(OptimizablePredicateList predList) throws StandardException
Optimizable
uniqueJoin
in interface Optimizable
uniqueJoin
in class FromTable
StandardException
- Thrown on errorOptimizable.uniqueJoin(org.apache.derby.iapi.sql.compile.OptimizablePredicateList)
PredicateList getRestrictionList()
java.lang.String getUserSpecifiedJoinStrategy()
getUserSpecifiedJoinStrategy
in class FromTable
public void printSubNodes(int depth)
printSubNodes
in class SingleChildResultSetNode
depth
- The depth of this node in the tree
public ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException
preprocess
in class SingleChildResultSetNode
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 predicateList) throws StandardException
pushExpressions
in class SingleChildResultSetNode
predicateList
- The PredicateList.
StandardException
- Thrown on errorpublic ResultSetNode addNewPredicate(Predicate predicate) throws StandardException
addNewPredicate
in class SingleChildResultSetNode
predicate
- The predicate to add
StandardException
- Thrown on errorpublic boolean flattenableInFromSubquery(FromList fromList)
flattenableInFromSubquery
in class SingleChildResultSetNode
fromList
- The outer from list
public ResultSetNode ensurePredicateList(int numTables) throws StandardException
ensurePredicateList
in class SingleChildResultSetNode
numTables
- The number of tables in the query.
StandardException
- Thrown on errorpublic ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException
optimize
in class SingleChildResultSetNode
dataDictionary
- The DataDictionary to use for optimizationouterRows
- The number of outer joining rows
StandardException
- Thrown on errorpublic CostEstimate getCostEstimate()
getCostEstimate
in class ResultSetNode
public CostEstimate getFinalCostEstimate()
getFinalCostEstimate
in class SingleChildResultSetNode
public 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 generateResultSet(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
generateResultSet
in class ResultSetNode
mb
- The method the expression will go into
StandardException
- Thrown on errorprivate void generateMinion(ExpressionClassBuilder acb, MethodBuilder mb, boolean genChildResultSet) throws StandardException
mb
- The method the expression will go into
StandardException
- Thrown on errorboolean nopProjectRestrict()
public void generateNOPProjectRestrict() throws StandardException
StandardException
- Thrown on errorpublic ResultSetNode considerMaterialization(JBitSet outerTables) throws StandardException
considerMaterialization
in class ResultSetNode
StandardException
- Thrown on errorprotected FromTable getFromTableByName(java.lang.String name, java.lang.String schemaName, boolean exactMatch) throws StandardException
getFromTableByName
in class SingleChildResultSetNode
name
- The specified name to search for as an exposed name.schemaName
- Schema name, if non-null.exactMatch
- Whether or not we need an exact match on specified schema and table
names or match on table id.
StandardException
- Thrown on errorpublic int updateTargetLockMode()
updateTargetLockMode
in class SingleChildResultSetNode
boolean isPossibleDistinctScan()
isPossibleDistinctScan
in class ResultSetNode
void markForDistinctScan()
markForDistinctScan
in class ResultSetNode
public Visitable accept(Visitor v) throws StandardException
accept
in interface Visitable
accept
in class SingleChildResultSetNode
v
- the visitor
StandardException
- on errorpublic void setRefActionInfo(long fkIndexConglomId, int[] fkColArray, java.lang.String parentResultSetId, boolean dependentScan)
setRefActionInfo
in class QueryTreeNode
public void init(java.lang.Object childResult, java.lang.Object tableProperties)
init
in class FromTable
childResult
- The child ResultSetNodetableProperties
- Properties list associated with the tablepublic ResultSetNode getChildResult()
void setChildResult(ResultSetNode childResult)
childResult
- The new childResult for this node.
public boolean forUpdate()
Optimizable
forUpdate
in interface Optimizable
forUpdate
in class FromTable
Optimizable.forUpdate()
public void initAccessPaths(Optimizer optimizer)
Optimizable
initAccessPaths
in interface Optimizable
initAccessPaths
in class FromTable
Optimizable.initAccessPaths(org.apache.derby.iapi.sql.compile.Optimizer)
public boolean referencesTarget(java.lang.String name, boolean baseTable) throws StandardException
referencesTarget
in class ResultSetNode
name
- Table name (String) to search for.baseTable
- Whether or not name is for a base table
StandardException
- Thrown on errorpublic boolean referencesSessionSchema() throws StandardException
referencesSessionSchema
in class QueryTreeNode
StandardException
- Thrown on errorpublic void setLevel(int level)
setLevel
in class FromTable
level
- The query block level for this FromTable.
boolean subqueryReferencesTarget(java.lang.String name, boolean baseTable) throws StandardException
subqueryReferencesTarget
in class ResultSetNode
name
- The table name.baseTable
- Whether or not the name is for a base table.
StandardException
- Thrown on errorpublic ResultSetNode modifyAccessPaths() throws StandardException
ResultSetNode
modifyAccessPaths
in class ResultSetNode
StandardException
- Thrown on errorResultSetNode.modifyAccessPaths()
public ResultSetNode changeAccessPath() throws StandardException
ResultSetNode
changeAccessPath
in class ResultSetNode
StandardException
- Thrown on errorResultSetNode.changeAccessPath()
void decrementLevel(int decrement)
decrementLevel
in class FromTable
decrement
- The amount to decrement by.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 boolean isOneRowResultSet() throws StandardException
isOneRowResultSet
in class ResultSetNode
StandardException
- Thrown on errorpublic boolean isNotExists()
isNotExists
in class ResultSetNode
protected boolean reflectionNeededForProjection()
void replaceDefaults(TableDescriptor ttd, ResultColumnList tcl) throws StandardException
replaceDefaults
in class ResultSetNode
ttd
- The TableDescriptor for the target table.tcl
- The RCL for the target table.
StandardException
- Thrown on errorvoid markOrderingDependent()
markOrderingDependent
in class ResultSetNode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |