|
|||||||||
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.FromVTI
public class FromVTI
A FromVTI represents a VTI in the FROM list of a DML statement.
Field Summary | |
---|---|
private FormatableHashtable |
compileTimeConstants
|
private boolean |
controlsDeferral
|
(package private) JBitSet |
correlationMap
|
(package private) JBitSet |
dependencyMap
|
private boolean |
emptyForUpdate
Was the FOR UPDATE clause empty (no columns specified). |
(package private) double |
estimatedCost
|
(package private) double |
estimatedRowCount
|
(package private) TableName |
exposedName
|
private boolean |
forUpdatePresent
Was a FOR UPDATE clause specified in a SELECT statement. |
private boolean |
implementsPushable
|
(package private) boolean |
implementsVTICosting
|
(package private) boolean |
isDerbyStyleTableFunction
|
private boolean |
isInsensitive
|
(package private) boolean |
isRestrictedTableFunction
|
(package private) boolean |
isTarget
|
(package private) boolean |
materializable
|
(package private) MethodCallNode |
methodCall
|
private JavaValueNode[] |
methodParms
|
protected int |
numVTICols
|
(package private) boolean |
optimized
|
private java.lang.String[] |
projectedColumnNames
|
private java.sql.PreparedStatement |
ps
|
private PredicateList |
restrictionList
|
private int |
resultSetType
|
(package private) java.sql.ResultSet |
rs
|
(package private) SubqueryList |
subqueryList
|
(package private) boolean |
supportsMultipleInstantiations
|
protected boolean |
version2
|
(package private) boolean |
vtiCosted
|
private Restriction |
vtiRestriction
|
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 | |
---|---|
FromVTI()
|
Method Summary | |
---|---|
(package private) void |
acceptChildren(Visitor v)
Accept the visitor for all visitable children of this node. |
void |
adjustForSortElimination()
Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort. |
void |
bindExpressions(FromList fromListParam)
Bind the expressions in this VTI. |
ResultSetNode |
bindNonVTITables(DataDictionary dataDictionary,
FromList fromListParam)
Bind the non VTI tables in this ResultSetNode. |
ResultSetNode |
bindVTITables(FromList fromListParam)
Bind this VTI that appears in the FROM list. |
private boolean |
canBePushedDown(Predicate predicate)
Return true if the predicate can be pushed into a RestrictedVTI |
private java.util.HashMap |
computeProjection()
Fills in the array of projected column names suitable for handing to RestrictedVTI.initScan(). |
(package private) void |
computeProjectionAndRestriction(PredicateList parentPredicates)
Compute the projection and restriction to be pushed to the external table function if it is a RestrictedVTI. |
private void |
computeRestriction(PredicateList parentPredicates,
java.util.HashMap columnNameMap)
Fills in the restriction to be handed to a RestrictedVTI at run-time. |
private void |
createResultColumnsForTableFunction(TypeDescriptor td)
Add result columns for a Derby-style Table Function |
CostEstimate |
estimateCost(OptimizablePredicateList predList,
ConglomerateDescriptor cd,
CostEstimate outerCost,
Optimizer optimizer,
RowOrdering rowOrdering)
Estimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate. |
private int |
flipOperator(int rawOperator)
Flip the sense of a comparison |
void |
generate(ActivationClassBuilder acb,
MethodBuilder mb)
Generation on a FromVTI creates a wrapper around the user's java.sql.ResultSet |
private void |
generateConstructor(ActivationClassBuilder acb,
MethodBuilder mb,
boolean reuseablePs)
|
protected ResultSetNode |
genProjectRestrict(int numTables)
Put a ProjectRestrictNode on top of each FromTable in the FromList. |
private ResultColumnList |
genResultColList(TableDescriptor td)
|
ResultColumnList |
getAllResultColumns(TableName allTableName)
Expand a "*" into a ResultColumnList with all of the result columns from the subquery. |
DeferModification |
getDeferralControl()
Get the DeferModification interface associated with this VTI |
java.lang.String |
getExposedName()
Get the exposed name for this table, which is the name that can be used to refer to it in the rest of the query. |
TableName |
getExposedTableName()
|
private int[] |
getForUpdateColumnList()
|
ResultColumn |
getMatchingColumn(ColumnReference columnReference)
Try to find a ResultColumn in the table represented by this FromBaseTable that matches the name in the given ColumnReference. |
MethodCallNode |
getMethodCall()
Return the constructor or static method invoked from this node |
private java.lang.Object |
getNewInstance()
|
(package private) java.util.Vector |
getNodesFromParameters(java.lang.Class nodeClass)
Get all of the nodes of the specified class from the parameters to this VTI. |
java.lang.String |
getOriginalSQL()
Return the SQL text of the original SQL statement. |
java.sql.ResultSetMetaData |
getResultSetMetaData()
Get the ResultSetMetaData for the class/object. |
int |
getResultSetType()
|
private int |
getScanArguments(ActivationClassBuilder acb,
MethodBuilder mb)
|
java.lang.Object |
getSharedState(java.lang.String key)
Get an object associated with a key from set of objects maintained with the statement plan. |
private UUID |
getSpecialTriggerVTITableName(LanguageConnectionContext lcc,
java.lang.String className)
Check and see if we have a special trigger VTI. |
int |
getStatementIsolationLevel()
Get the specific JDBC isolation of the statement. |
private VTICosting |
getVTICosting()
Get the VTICosting implementation for this optimizable VTI. |
(package private) java.lang.String |
getVTIName()
|
private Restriction |
iAmConfused(ValueNode clause)
This is a handy place to put instrumentation for tracing trees which we don't understand |
private boolean |
implementsDerbyStyleVTICosting(java.lang.String className)
Return true if this Derby Style Table Function implements the VTICosting interface. |
void |
init(java.lang.Object invocation,
java.lang.Object correlationName,
java.lang.Object derivedRCL,
java.lang.Object tableProperties)
Initialize a query tree node. |
void |
init(java.lang.Object invocation,
java.lang.Object correlationName,
java.lang.Object derivedRCL,
java.lang.Object tableProperties,
java.lang.Object exposedTableName)
Initialize a query tree node. |
boolean |
isCompileTime()
Return true if this instance of the Table Function has been created for compilation, false if it is for runtime execution. |
boolean |
isConstructor()
Return true if this VTI is a constructor. |
boolean |
isMaterializable()
Tell whether this Optimizable is materializable |
(package private) boolean |
isUpdatableCursor()
|
boolean |
legalJoinOrder(JBitSet assignedTableMap)
Can this Optimizable appear at the current location in the join order. |
private java.lang.Class |
lookupClass(java.lang.String className)
Lookup the class that holds the VTI. |
private Restriction |
makeIsNullRestriction(IsNullNode clause,
java.util.HashMap columnNameMap)
Makes an IS NULL comparison of a column in the VTI. |
private Restriction |
makeLeafRestriction(BinaryRelationalOperatorNode clause,
java.util.HashMap columnNameMap)
Makes a Restriction out of a comparison between a constant and a column in the VTI. |
private Restriction |
makeRestriction(ValueNode clause,
java.util.HashMap columnNameMap)
Turn a compile-time WHERE clause fragment into a run-time Restriction. |
private int |
mapOperator(int rawOperator)
Map internal operator constants to user-visible ones |
protected void |
markUpdatableByCursor(java.util.Vector updateColumns)
Mark as updatable all the columns in the result column list of this FromBaseTable that match the columns in the given update column list. |
Optimizable |
modifyAccessPath(JBitSet outerTables)
Modify the access path for this Optimizable, as necessary. |
boolean |
needsSpecialRCLBinding()
|
boolean |
performMaterialization(JBitSet outerTables)
Return whether or not to materialize this ResultSet tree. |
ResultSetNode |
preprocess(int numTables,
GroupByList gbl,
FromList fromList)
Preprocess a ResultSetNode - this currently means: o Generating a referenced table map for each ResultSetNode. |
void |
printSubNodes(int depth)
Prints the sub-nodes of this object. |
boolean |
pushOptPredicate(OptimizablePredicate optimizablePredicate)
Push an OptimizablePredicate down, if this node accepts it. |
boolean |
referencesTarget(java.lang.String name,
boolean baseTable)
Search to see if a query references the specifed table name. |
void |
setSharedState(java.lang.String key,
java.io.Serializable value)
Saves an object associated with a key that will be maintained for the lifetime of the statement plan. |
(package private) void |
setTarget()
Mark this VTI as the target of a delete or update. |
private java.lang.Object |
squeezeConstantValue(ValueNode valueNode)
Get the constant or parameter reference out of a comparand. |
private int |
storeObjectInPS(ActivationClassBuilder acb,
java.lang.Object obj)
Store an object in the prepared statement. |
boolean |
supportsMultipleInstantiations()
Tell whether this Optimizable can be instantiated multiple times |
java.lang.String |
toString()
Convert this object to a String. |
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 |
---|
JBitSet correlationMap
JBitSet dependencyMap
MethodCallNode methodCall
TableName exposedName
SubqueryList subqueryList
boolean implementsVTICosting
boolean optimized
boolean materializable
boolean isTarget
boolean isDerbyStyleTableFunction
boolean isRestrictedTableFunction
java.sql.ResultSet rs
private FormatableHashtable compileTimeConstants
protected int numVTICols
private PredicateList restrictionList
private boolean forUpdatePresent
private boolean emptyForUpdate
double estimatedCost
double estimatedRowCount
boolean supportsMultipleInstantiations
boolean vtiCosted
protected boolean version2
private boolean implementsPushable
private java.sql.PreparedStatement ps
private JavaValueNode[] methodParms
private boolean controlsDeferral
private boolean isInsensitive
private int resultSetType
private java.lang.String[] projectedColumnNames
private Restriction vtiRestriction
Constructor Detail |
---|
public FromVTI()
Method Detail |
---|
public void init(java.lang.Object invocation, java.lang.Object correlationName, java.lang.Object derivedRCL, java.lang.Object tableProperties) throws StandardException
QueryTreeNode
init
in class QueryTreeNode
invocation
- The constructor or static method for the VTIcorrelationName
- The correlation namederivedRCL
- The derived column listtableProperties
- Properties list associated with the table
StandardException
- Thrown on errorpublic void init(java.lang.Object invocation, java.lang.Object correlationName, java.lang.Object derivedRCL, java.lang.Object tableProperties, java.lang.Object exposedTableName) throws StandardException
QueryTreeNode
init
in class QueryTreeNode
invocation
- The constructor or static method for the VTIcorrelationName
- The correlation namederivedRCL
- The derived column listtableProperties
- Properties list associated with the tableexposedTableName
- The table name (TableName class)
StandardException
- Thrown on errorpublic CostEstimate estimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) throws StandardException
Optimizable
estimateCost
in interface Optimizable
estimateCost
in class FromTable
predList
- The predicate list to optimize againstcd
- The conglomerate descriptor to get the cost ofouterCost
- The estimated cost of the part of the plan outer
to this optimizable.optimizer
- The optimizer to use to help estimate the costrowOrdering
- The row ordering for all the tables in the
join order, including this one.
StandardException
- Thrown on errorOptimizable.estimateCost(org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, org.apache.derby.iapi.sql.compile.CostEstimate, org.apache.derby.iapi.sql.compile.Optimizer, org.apache.derby.iapi.sql.compile.RowOrdering)
public boolean legalJoinOrder(JBitSet assignedTableMap)
Optimizable
legalJoinOrder
in interface Optimizable
legalJoinOrder
in class FromTable
assignedTableMap
- The tables that have been placed so far in the join order.
Optimizable.legalJoinOrder(org.apache.derby.iapi.util.JBitSet)
public boolean isMaterializable()
Optimizable
isMaterializable
in interface Optimizable
isMaterializable
in class FromTable
Optimizable.isMaterializable()
public boolean supportsMultipleInstantiations()
Optimizable
supportsMultipleInstantiations
in interface Optimizable
supportsMultipleInstantiations
in class FromTable
Optimizable.supportsMultipleInstantiations()
public void adjustForSortElimination()
ResultSetNode
adjustForSortElimination
in class ResultSetNode
ResultSetNode.adjustForSortElimination()
public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException
Optimizable
modifyAccessPath
in interface Optimizable
modifyAccessPath
in class FromTable
outerTables
- Bit map of the tables that are outer to this one
in the join order.
StandardException
- Thrown on errorOptimizable.modifyAccessPath(org.apache.derby.iapi.util.JBitSet)
public boolean pushOptPredicate(OptimizablePredicate optimizablePredicate) throws StandardException
Optimizable
pushOptPredicate
in interface Optimizable
pushOptPredicate
in class FromTable
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 FromTable
public void printSubNodes(int depth)
printSubNodes
in class ResultSetNode
depth
- The depth of this node in the treepublic boolean isConstructor()
public MethodCallNode getMethodCall()
public java.lang.String getExposedName()
getExposedName
in class FromTable
public TableName getExposedTableName()
void setTarget()
public ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException
bindNonVTITables
in class ResultSetNode
dataDictionary
- The DataDictionary to use for bindingfromListParam
- FromList to use/append to.
StandardException
- Thrown on errorjava.lang.String getVTIName()
public ResultSetNode bindVTITables(FromList fromListParam) throws StandardException
bindVTITables
in class ResultSetNode
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic java.sql.ResultSetMetaData getResultSetMetaData() throws StandardException
StandardException
- Thrown on errorprivate java.lang.Object getNewInstance() throws StandardException
StandardException
public DeferModification getDeferralControl() throws StandardException
StandardException
public int getResultSetType()
public void bindExpressions(FromList fromListParam) throws StandardException
bindExpressions
in class ResultSetNode
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorjava.util.Vector getNodesFromParameters(java.lang.Class nodeClass) throws StandardException
nodeClass
- The Class of interest.
StandardException
- Thrown on errorpublic ResultColumnList getAllResultColumns(TableName allTableName) throws StandardException
getAllResultColumns
in class ResultSetNode
allTableName
- The qualifier on the "*"
null
if
allTableName
is non-null and doesn't match a table name in
this result set
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 ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException
preprocess
in class ResultSetNode
numTables
- The number of tables in the DML Statementgbl
- The group by list, if anyfromList
- The from list, if any
StandardException
- Thrown on errorprotected ResultSetNode genProjectRestrict(int numTables) throws StandardException
genProjectRestrict
in class ResultSetNode
numTables
- Number of tables in the DML Statement
StandardException
- Thrown on errorpublic boolean performMaterialization(JBitSet outerTables) throws StandardException
performMaterialization
in class ResultSetNode
StandardException
- Thrown on errorvoid computeProjectionAndRestriction(PredicateList parentPredicates) throws StandardException
parentPredicates
- The full list of predicates to be applied by the parent ProjectRestrictNode
StandardException
private java.util.HashMap computeProjection() throws StandardException
StandardException
private void computeRestriction(PredicateList parentPredicates, java.util.HashMap columnNameMap) throws StandardException
parentPredicates
- The full list of predicates to be applied by the parent ProjectRestrictNodecolumnNameMap
- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
StandardException
private boolean canBePushedDown(Predicate predicate) throws StandardException
StandardException
private Restriction makeRestriction(ValueNode clause, java.util.HashMap columnNameMap) throws StandardException
clause
- The clause which should be turned into a Restriction.columnNameMap
- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
StandardException
private Restriction makeLeafRestriction(BinaryRelationalOperatorNode clause, java.util.HashMap columnNameMap) throws StandardException
clause
- The clause which should be turned into a Restriction.columnNameMap
- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
StandardException
private Restriction makeIsNullRestriction(IsNullNode clause, java.util.HashMap columnNameMap) throws StandardException
clause
- The IS NULL (or IS NOT NULL) nodecolumnNameMap
- Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
StandardException
private Restriction iAmConfused(ValueNode clause) throws StandardException
StandardException
private int flipOperator(int rawOperator) throws StandardException
StandardException
private int mapOperator(int rawOperator) throws StandardException
StandardException
private java.lang.Object squeezeConstantValue(ValueNode valueNode) throws StandardException
StandardException
public void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
generate
in class QueryTreeNode
acb
- The ActivationClassBuilder for the class being builtmb
- The MethodBuilder for the execute() method to be built
StandardException
- Thrown on errorprivate int getScanArguments(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
StandardException
private int storeObjectInPS(ActivationClassBuilder acb, java.lang.Object obj) throws StandardException
StandardException
private void generateConstructor(ActivationClassBuilder acb, MethodBuilder mb, boolean reuseablePs) throws StandardException
StandardException
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 errorvoid acceptChildren(Visitor v) throws StandardException
acceptChildren
in class ResultSetNode
v
- the visitor
StandardException
- on errorprivate UUID getSpecialTriggerVTITableName(LanguageConnectionContext lcc, java.lang.String className) throws StandardException
StandardException
private ResultColumnList genResultColList(TableDescriptor td) throws StandardException
StandardException
public boolean needsSpecialRCLBinding()
needsSpecialRCLBinding
in class FromTable
boolean isUpdatableCursor() throws StandardException
StandardException
protected void markUpdatableByCursor(java.util.Vector updateColumns)
FromTable
markUpdatableByCursor
in class FromTable
updateColumns
- A Vector representing the columns
that can be updated.private int[] getForUpdateColumnList()
public final boolean isCompileTime()
VTIEnvironment
isCompileTime
in interface VTIEnvironment
public java.lang.String getOriginalSQL()
VTIEnvironment
getOriginalSQL
in interface VTIEnvironment
public final int getStatementIsolationLevel()
VTIEnvironment
getStatementIsolationLevel
in interface VTIEnvironment
public void setSharedState(java.lang.String key, java.io.Serializable value)
VTIEnvironment
setSharedState
in interface VTIEnvironment
public java.lang.Object getSharedState(java.lang.String key)
VTIEnvironment
getSharedState
in interface VTIEnvironment
private void createResultColumnsForTableFunction(TypeDescriptor td) throws StandardException
StandardException
private boolean implementsDerbyStyleVTICosting(java.lang.String className) throws StandardException
StandardException
private VTICosting getVTICosting() throws StandardException
StandardException
private java.lang.Class lookupClass(java.lang.String className) throws StandardException
StandardException
|
Built on Thu 2011-03-10 11:54:14+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |