Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class FromVTI

extends FromTable
implements VTIEnvironment
Class Inheritance
All Implemented Interfaces
org.apache.derby.vti.VTIEnvironment
Imports
java.lang.reflect.Constructor, .InvocationTargetException, .Method, .Modifier, java.sql.PreparedStatement, .ResultSet, .ResultSetMetaData, .SQLException, java.util.ArrayList, .HashMap, .List, .Properties, org.apache.derby.catalog.DefaultInfo, .TypeDescriptor, .UUID, org.apache.derby.catalog.types.RoutineAliasInfo, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, .SQLState, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.LocalField, .MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.io.FormatableBitSet, .FormatableHashtable, org.apache.derby.iapi.services.loader.ClassInspector, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CostEstimate, .Optimizable, .OptimizablePredicate, .OptimizablePredicateList, .Optimizer, .RowOrdering, .Visitable, .Visitor, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.dictionary.ColumnDescriptor, .ColumnDescriptorList, .ConglomerateDescriptor, .DataDictionary, .TableDescriptor, org.apache.derby.iapi.transaction.TransactionControl, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, org.apache.derby.iapi.util.JBitSet, org.apache.derby.vti.DeferModification, .RestrictedVTI, .Restriction, .VTICosting, .VTIEnvironment

A FromVTI represents a VTI in the FROM list of a DML statement.

Field Summary

Modifier and TypeField and Description
private HashMap<Integer, FromTable>
private final FormatableHashtable
private boolean
pack-priv JBitSet
pack-priv JBitSet
pack-priv double
pack-priv double
pack-priv TableName
private boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv boolean
pack-priv MethodCallNode
private JavaValueNode[]
protected int
pack-priv boolean
private ArrayList<FromList>
private String[]
private PreparedStatement
private PredicateList
private int
pack-priv ResultSet
pack-priv SubqueryList
pack-priv boolean
protected boolean
pack-priv boolean
private Restriction
Inherited from org.apache.derby.impl.sql.compile.FromTable:
ADD_PLANbestAccessPathbestCostEstimatebestSortAvoidancePathcorrelationNamecorrTableNamecurrentAccessPathhashKeyColumnsinitialCapacitylevelLOAD_PLANloadFactormaxCapacityorigTableNameREMOVE_PLANtableNumbertablePropertiestrulyTheBestAccessPathuserSpecifiedJoinStrategy

Constructor Summary

AccessConstructor and Description
pack-priv
FromVTI(MethodCallNode
The constructor or static method for the VTI
invocation
,
String
The correlation name
correlationName
,
ResultColumnList
The derived column list
derivedRCL
,
Properties
Properties list associated with the table
tableProperties
,
ContextManager cm)

Constructor.

pack-priv
FromVTI(MethodCallNode
The constructor or static method for the VTI
invocation
,
String
The correlation name
correlationName
,
ResultColumnList
The derived column list
derivedRCL
,
Properties
Properties list associated with the table
tableProperties
,
TableName
The table name (TableName class)
exposedTableName
,
ContextManager
The context manager
cm
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.FromTable.acceptChildren.

Accept the visitor for all visitable children of this node.

public void
addOuterFromList(FromList fromList)

Add a FromList to the collection of FromLists which bindExpressions() checks when vetting VTI arguments which reference columns in other tables.

pack-priv void
adjustForSortElimination()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort.

pack-priv void
bindExpressions(FromList
FromList to use/append to.
fromListParam
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindExpressions.

Bind the expressions in this VTI.

pack-priv ResultSetNode

Returns:

ResultSetNode
bindNonVTITables
(DataDictionary
The DataDictionary to use for binding
dataDictionary
,
FromList
FromList to use/append to.
fromListParam
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindNonVTITables.

Bind the non VTI tables in this ResultSetNode.

pack-priv ResultSetNode

Returns:

ResultSetNode The bound FromVTI.
bindVTITables
(FromList
FromList to use/append to.
fromListParam
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindVTITables.

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 FromTable
columnInFromList(FromList fromList, ColumnReference ref)

If the referenced column appears in the indicated FROM list, then return the table it appears in.

private HashMap<String, String>
computeProjection()

Fills in the array of projected column names suitable for handing to RestrictedVTI.initScan().

pack-priv void
computeProjectionAndRestriction(PredicateList
The full list of predicates to be applied by the parent ProjectRestrictNode
parentPredicates
)

Compute the projection and restriction to be pushed to the external table function if it is a RestrictedVTI.

private void
computeRestriction(PredicateList
The full list of predicates to be applied by the parent ProjectRestrictNode
parentPredicates
,
HashMap<String, String>
Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
columnNameMap
)

Fills in the restriction to be handed to a RestrictedVTI at run-time.

private void
constructorMinion(MethodCallNode invocation, ResultColumnList derivedRCL, TableName exposedTableName)

private void
createResultColumnsForTableFunction(TypeDescriptor td)

Add result columns for a Derby-style Table Function

public CostEstimate
estimateCost(OptimizablePredicateList
The predicate list to optimize against
predList
,
ConglomerateDescriptor
The conglomerate descriptor to get the cost of
cd
,
CostEstimate
The estimated cost of the part of the plan outer to this optimizable.
outerCost
,
Optimizer
The optimizer to use to help estimate the cost
optimizer
,
RowOrdering
The row ordering for all the tables in the join order, including this one.
rowOrdering
)

Overrides org.apache.derby.impl.sql.compile.FromTable.estimateCost.

Implements org.apache.derby.iapi.sql.compile.Optimizable.estimateCost.

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

pack-priv void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The MethodBuilder for the execute() method to be built
mb
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

Generation on a FromVTI creates a wrapper around the user's java.sql.ResultSet

private void
protected ResultSetNode

Returns:

The generated ProjectRestrictNode atop the original FromTable.
genProjectRestrict
(int
Number of tables in the DML Statement
numTables
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.genProjectRestrict.

Put a ProjectRestrictNode on top of each FromTable in the FromList.

private ResultColumnList
pack-priv ResultColumnList
getAllResultColumns(TableName
The qualifier on the "*"
allTableName
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.getAllResultColumns.

Expand a "*" into a ResultColumnList with all of the result columns from the subquery.

public DeferModification

Returns:

null if the VTI uses the default modification deferral
getDeferralControl
()

Get the DeferModification interface associated with this VTI

pack-priv String

Returns:

The exposed name for this table.
getExposedName
()

Overrides org.apache.derby.impl.sql.compile.FromTable.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.

public TableName

Returns:

the table name used for matching with column references.
getExposedTableName
()

pack-priv ResultColumn

Returns:

A ResultColumn whose expression is the ColumnNode that matches the ColumnReference. Returns null if there is no match.
getMatchingColumn
(ColumnReference
The columnReference whose name we're looking for in the given table.
columnReference
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.getMatchingColumn.

Try to find a ResultColumn in the table represented by this FromBaseTable that matches the name in the given ColumnReference.

pack-priv final MethodCallNode
getMethodCall()

Return the constructor or static method invoked from this node

private Object
pack-priv <T extends Visitable> List<T>

Returns:

A list containing all of the nodes of interest.
getNodesFromParameters
(Class<T>
The Class of interest.
nodeClass
)

Get all of the nodes of the specified class from the parameters to this VTI.

public String
getOriginalSQL()

Implements org.apache.derby.vti.VTIEnvironment.getOriginalSQL.

Return the SQL text of the original SQL statement.

pack-priv ResultSetMetaData

Returns:

The ResultSetMetaData from the class/object.
getResultSetMetaData
()

Get the ResultSetMetaData for the class/object.

public int

Returns:

the ResultSet type of the VTI, TYPE_FORWARD_ONLY if the getResultSetType() method of the VTI class throws an exception.
getResultSetType
()

private int
public Object
getSharedState(String
Key into a cache of context variables
key
)

Implements org.apache.derby.vti.VTIEnvironment.getSharedState.

Get an object associated with a key from set of objects maintained with the statement plan.

private UUID

Returns:

null if not a special trigger vti, or the table id if it is
getSpecialTriggerVTITableName
(LanguageConnectionContext lcc, String className)

Check and see if we have a special trigger VTI.

public final int
getStatementIsolationLevel()

Implements org.apache.derby.vti.VTIEnvironment.getStatementIsolationLevel.

Get the specific JDBC isolation of the statement.

private VTICosting
getVTICosting()

Get the VTICosting implementation for this optimizable VTI.

pack-priv String

Returns:

The name of the VTI, mainly for debugging and error messages.
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(String className)

Return true if this Derby Style Table Function implements the VTICosting interface.

public final boolean
isCompileTime()

Implements org.apache.derby.vti.VTIEnvironment.isCompileTime.

Return true if this instance of the Table Function has been created for compilation, false if it is for runtime execution.

pack-priv boolean
isConstructor()

Return true if this VTI is a constructor.

public boolean
isDerbyStyleTableFunction()

Return true if this is a user-defined table function

public boolean
pack-priv boolean
public boolean
legalJoinOrder(JBitSet
The tables that have been placed so far in the join order.
assignedTableMap
)

Overrides org.apache.derby.impl.sql.compile.FromTable.legalJoinOrder.

Implements org.apache.derby.iapi.sql.compile.Optimizable.legalJoinOrder.

Can this Optimizable appear at the current location in the join order.

private Class<?>
lookupClass(String className)

Lookup the class that holds the VTI.

private Restriction
makeIsNullRestriction(IsNullNode
The IS NULL (or IS NOT NULL) node
clause
,
HashMap<String, String>
Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
columnNameMap
)

Makes an IS NULL comparison of a column in the VTI.

private Restriction
makeLeafRestriction(BinaryRelationalOperatorNode
The clause which should be turned into a Restriction.
clause
,
HashMap<String, String>
Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
columnNameMap
)

Makes a Restriction out of a comparison between a constant and a column in the VTI.

private Restriction
makeRestriction(ValueNode
The clause which should be turned into a Restriction.
clause
,
HashMap<String, String>
Mapping between the exposed column names used in the predicates and the actual column names declared for the table function at CREATE FUNCTION time.
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

public Optimizable
modifyAccessPath(JBitSet
Bit map of the tables that are outer to this one in the join order.
outerTables
)

Overrides org.apache.derby.impl.sql.compile.FromTable.modifyAccessPath.

Implements org.apache.derby.iapi.sql.compile.Optimizable.modifyAccessPath.

Modify the access path for this Optimizable, as necessary.

pack-priv boolean
pack-priv boolean

Returns:

Whether or not to materialize this ResultSet tree. would return valid results.
performMaterialization
(JBitSet outerTables)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.performMaterialization.

Return whether or not to materialize this ResultSet tree.

pack-priv ResultSetNode

Returns:

ResultSetNode at top of preprocessed tree.
preprocess
(int
The number of tables in the DML Statement
numTables
,
GroupByList
The group by list, if any
gbl
,
FromList
The from list, if any
fromList
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.preprocess.

Preprocess a ResultSetNode - this currently means: o Generating a referenced table map for each ResultSetNode.

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.printSubNodes.

Prints the sub-nodes of this object.

public boolean
pushOptPredicate(OptimizablePredicate
OptimizablePredicate to push down.
optimizablePredicate
)

Overrides org.apache.derby.impl.sql.compile.FromTable.pushOptPredicate.

Implements org.apache.derby.iapi.sql.compile.Optimizable.pushOptPredicate.

Push an OptimizablePredicate down, if this node accepts it.

pack-priv boolean

Returns:

true if found, else false
referencesTarget
(String
Table name (String) to search for.
name
,
boolean
Whether or not name is for a base table
baseTable
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.referencesTarget.

Search to see if a query references the specifed table name.

private void
remapBaseTableColumns()

Remap the column references in vti arguments.

public void
setSharedState(String
Key into a cache of context variables
key
,
Serializable
Value to associate with the key
value
)

Implements org.apache.derby.vti.VTIEnvironment.setSharedState.

Saves an object associated with a key that will be maintained for the lifetime of the statement plan.

pack-priv void
setTarget()

Mark this VTI as the target of a delete or update.

private Object
squeezeConstantValue(ValueNode valueNode)

Get the constant or parameter reference out of a comparand.

private int
storeObjectInPS(ActivationClassBuilder acb, Object obj)

Store an object in the prepared statement.

public boolean
public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.FromTable.toString.

Convert this object to a String.

Inherited from org.apache.derby.impl.sql.compile.FromTable:
assignCostEstimatecanBeOrderedcolumnsAreUpdatableconsiderSortAvoidancePathconvertAbsoluteToRelativeColumnPositioncursorTargetTabledecrementLevelfeasibleJoinStrategyfillInReferencedTableMapflattenforUpdategetBaseTableNamegetBestAccessPathgetBestSortAvoidancePathgetCorrelationNamegetCostEstimategetCurrentAccessPathgetFinalCostEstimategetFromTableByNamegetLevelgetMergeTableIDgetNamegetNumColumnsReturnedgetOrigTableNamegetPropertiesgetResultColumnsForListgetSchemaDescriptorgetSchemaDescriptorgetScratchCostEstimategetTableDescriptorgetTableNamegetTableNumbergetTrulyTheBestAccessPathgetUserSpecifiedJoinStrategyhashKeyColumnshasLargeObjectColumnshasTableNumberinitAccessPathsinitialCapacityisBaseTableisCoveringIndexisFlattenableJoinNodeisJoinColumnForRightOuterJoinisOneRowScanisTargetTableloadFactorLOJ_reorderablemarkUpdatableByCursormaxCapacitymemoryUsageOKnextAccessPathoptimizeItoptimizeSubqueriespullOptPredicatespushExpressionsrememberAsBestrememberJoinStrategyAsBestrememberSortAvoidancePathresetJoinStrategiessetCostEstimateCostsetHashKeyColumnssetLevelsetMergeTableIDsetOrigTableNamesetPropertiessetTableNumberstartOptimizingtellRowOrderingAboutConstantColumnstransformOuterJoinsuniqueJoinupdateBestPlanMapverifyProperties