|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> sql >> [ compile overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.sql.compile
Class FromBaseTable

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.FromBaseTable
- All Implemented Interfaces:
- org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.Visitable
- public class FromBaseTable
- extends FromTable
A FromBaseTable represents a table in the FROM list of a DML statement, as distinguished from a FromSubquery, which represents a subquery in the FROM list. A FromBaseTable may actually represent a view. During parsing, we can't distinguish views from base tables. During binding, when we find FromBaseTables that represent views, we replace them with FromSubqueries. By the time we get to code generation, all FromSubqueries have been eliminated, and all FromBaseTables will represent only true base tables.
Positioned Update: Currently, all columns of an updatable cursor are selected to deal with a positioned update. This is because we don't know what columns will ultimately be needed from the UpdateNode above us. For example, consider:
get c as 'select cint from t for update of ctinyint' update t set ctinyint = csmallintIdeally, the cursor only selects cint. Then, something akin to an IndexRowToBaseRow is generated to take the CursorResultSet and get the appropriate columns out of the base table from the RowLocation retunrned by the cursor. Then the update node can generate the appropriate NormalizeResultSet (or whatever else it might need) to get things into the correct format for the UpdateResultSet. See CurrentOfNode for more information.
| 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 | |
FromBaseTable()
|
|
| Method Summary | |
ResultColumnList |
addColsToList(ResultColumnList inputRcl,
org.apache.derby.iapi.services.io.FormatableBitSet colsWeWant)
Augment the RCL to include the columns in the FormatableBitSet. |
private long |
baseRowCount()
|
void |
bindExpressions(FromList fromListParam)
Bind the expressions in this FromBaseTable. |
ResultSetNode |
bindNonVTITables(org.apache.derby.iapi.sql.dictionary.DataDictionary dataDictionary,
FromList fromListParam)
Bind the table in this FromBaseTable. |
void |
bindResultColumns(FromList fromListParam)
Bind the result columns of this ResultSetNode when there is no base table to bind them to. |
private org.apache.derby.iapi.sql.dictionary.TableDescriptor |
bindTableDescriptor()
Bind the table descriptor for this table. |
protected boolean |
canBeOrdered()
Tell super-class that this Optimizable can be ordered |
ResultSetNode |
changeAccessPath()
The optimizer's decision on the access path for a result set may require the generation of extra result sets. |
(package private) void |
clearDependency(java.util.Vector locations)
Clear the bits from the dependency map when join nodes are flattened |
int |
convertAbsoluteToRelativeColumnPosition(int absolutePosition)
Convert an absolute to a relative 0-based column position. |
protected boolean |
cursorTargetTable()
Is this a table that has a FOR UPDATE clause? |
(package private) void |
disableBulkFetch()
Turn off bulk fetch |
(package private) void |
doSpecialMaxScan()
Do a special scan for max. |
org.apache.derby.iapi.sql.compile.CostEstimate |
estimateCost(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
org.apache.derby.iapi.sql.compile.CostEstimate outerCost,
org.apache.derby.iapi.sql.compile.Optimizer optimizer,
org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering)
Estimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate. |
boolean |
forUpdate()
Return true if this is the target table of an update |
void |
generate(ActivationClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
Generation on a FromBaseTable creates a scan on the optimizer-selected conglomerate. |
private void |
generateDistinctScan(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
|
private void |
generateMaxSpecialResultSet(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
|
private void |
generateRefActionDependentTableScan(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
Generation on a FromBaseTable for a referential action dependent table. |
void |
generateResultSet(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
Generation on a FromBaseTable for a SELECT. |
protected ResultSetNode |
genProjectRestrict(int numTables)
Put a ProjectRestrictNode on top of each FromTable in the FromList. |
ResultColumnList |
genResultColList()
Build a ResultColumnList based on all of the columns in this FromBaseTable. |
ResultColumnList |
getAllResultColumns(TableName allTableName)
Return a ResultColumnList with all of the columns in this table. |
private org.apache.derby.iapi.store.access.StoreCostController |
getBaseCostController()
|
java.lang.String |
getBaseTableName()
Get the table name of this Optimizable. |
private void |
getConglomDescs()
|
private int |
getDefaultBulkFetch()
|
(package private) boolean |
getExistsBaseTable()
Does this FBT represent an EXISTS FBT. |
java.lang.String |
getExposedName()
Return the exposed name for this table, which is the name that can be used to refer to this table in the rest of the query. |
org.apache.derby.iapi.sql.compile.CostEstimate |
getFinalCostEstimate()
Get the final CostEstimate for this ResultSetNode. |
private org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor |
getFirstConglom()
|
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. |
ResultColumn |
getMatchingColumn(ColumnReference columnReference)
Try to find a ResultColumn in the table represented by this FromBaseTable that matches the name in the given ColumnReference. |
private org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor |
getNextConglom(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor currCD)
|
private org.apache.derby.iapi.types.DataValueDescriptor[] |
getRowTemplate(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
org.apache.derby.iapi.store.access.StoreCostController scc)
|
private int |
getScanArguments(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
|
private org.apache.derby.iapi.store.access.StoreCostController |
getStoreCostController(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd)
|
org.apache.derby.iapi.sql.dictionary.TableDescriptor |
getTableDescriptor()
Get the table descriptor for this table (if any). |
TableName |
getTableName()
Return a TableName node representing this FromTable. |
TableName |
getTableNameField()
Return the table name for this table. |
private java.lang.String |
getUserSpecifiedIndexName()
|
void |
init(java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4)
Initializer for a table in a FROM list. |
int |
initialCapacity()
Return the initial capacity of the hash table, for hash join strategy |
boolean |
isBaseTable()
Tell whether this Optimizable represents a base table |
boolean |
isCoveringIndex(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd)
Return whether or not this is a covering index. |
boolean |
isMaterializable()
Tell whether this Optimizable is materializable |
boolean |
isNotExists()
Return whether or not this is actually a EBT for NOT EXISTS. |
boolean |
isOneRowResultSet()
Return whether or not the underlying ResultSet tree will return a single row, at most. |
private boolean |
isOneRowResultSet(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList)
Is this a one-row result set with the given conglomerate descriptor? |
boolean |
isOneRowResultSet(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList)
|
boolean |
isOneRowScan()
Will the optimizable return at most 1 row per scan? |
private boolean |
isOrdered(ColumnReference[] crs,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd)
Return whether or not this index is ordered on a permutation of the specified columns. |
(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. |
private boolean |
isStrictlyOrdered(ColumnReference[] crs,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd)
Return whether or not this index is ordered on a permutation of the specified columns. |
boolean |
isTargetTable()
Is the optimizable the target table of an update or delete? |
boolean |
legalJoinOrder(org.apache.derby.iapi.util.JBitSet assignedTableMap)
Can this Optimizable appear at the current location in the join order. |
float |
loadFactor()
Return the load factor of the hash table, for hash join strategy |
boolean |
LOJ_reorderable(int numTables)
no LOJ reordering for base table. |
org.apache.derby.iapi.util.JBitSet |
LOJgetReferencedTables(int numTables)
|
private int |
mapAbsoluteToRelativeColumnPosition(int absolutePosition)
Convert an absolute to a relative 0-based column position. |
boolean |
markAsCursorTargetTable()
Mark this ResultSetNode as the target table of an updatable cursor. |
(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. |
(package private) void |
markUpdated(ResultColumnList 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. |
boolean |
memoryUsageOK(double rowCount,
int maxMemoryPerTable)
|
private ResultColumnList |
newResultColumns(ResultColumnList oldColumns,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor idxCD,
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor heapCD,
boolean cloneRCs)
Create a new ResultColumnList to reflect the columns in the index described by the given ConglomerateDescriptor. |
boolean |
nextAccessPath(org.apache.derby.iapi.sql.compile.Optimizer optimizer,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering)
Choose the next access path to evaluate for this Optimizable. |
org.apache.derby.iapi.sql.compile.CostEstimate |
optimizeIt(org.apache.derby.iapi.sql.compile.Optimizer optimizer,
org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
org.apache.derby.iapi.sql.compile.CostEstimate outerCost,
org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering)
Choose the best access path for this Optimizable. |
ResultSetNode |
preprocess(int numTables,
GroupByList gbl,
FromList fromList)
Preprocess a ResultSetNode - this currently means: o Generating a referenced table map for each ResultSetNode. |
void |
pullOptPredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList optimizablePredicates)
Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList. |
boolean |
pushOptPredicate(org.apache.derby.iapi.sql.compile.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. |
private double |
scanCostAfterSelectivity(double originalScanCost,
double initialPositionCost,
double selectivity,
boolean anotherIndexUnique)
|
(package private) void |
setExistsBaseTable(boolean existsBaseTable,
org.apache.derby.iapi.util.JBitSet dependencyMap,
boolean isNotExists)
Set whether or not this FBT represents an EXISTS FBT. |
private void |
setLockingBasedOnThreshold(org.apache.derby.iapi.sql.compile.Optimizer optimizer,
double rowsTouched)
|
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 |
setTableProperties(java.util.Properties tableProperties)
Set the table properties for this table. |
void |
startOptimizing(org.apache.derby.iapi.sql.compile.Optimizer optimizer,
org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering)
Begin the optimization process for this Optimizable. |
protected boolean |
supersetOfUniqueIndex(boolean[] eqCols)
Determine whether or not the columns marked as true in the passed in array are a superset of any unique index on this table. |
protected boolean |
supersetOfUniqueIndex(org.apache.derby.iapi.util.JBitSet[] tableColMap)
Determine whether or not the columns marked as true in the passed in join table matrix are a superset of any single column unique index on this table. |
java.lang.String |
toString()
Convert this object to a String. |
double |
uniqueJoin(org.apache.derby.iapi.sql.compile.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 table heap of an update or delete statement. |
void |
verifyProperties(org.apache.derby.iapi.sql.dictionary.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 |
UNSET
static final int UNSET
- See Also:
- Constant Field Values
tableName
TableName tableName
tableDescriptor
org.apache.derby.iapi.sql.dictionary.TableDescriptor tableDescriptor
baseConglomerateDescriptor
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor baseConglomerateDescriptor
conglomDescs
org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor[] conglomDescs
updateOrDelete
int updateOrDelete
bulkFetch
int bulkFetch
bulkFetchTurnedOff
boolean bulkFetchTurnedOff
singleScanRowCount
private double singleScanRowCount
referencedCols
private org.apache.derby.iapi.services.io.FormatableBitSet referencedCols
templateColumns
private ResultColumnList templateColumns
columnNames
private java.lang.String[] columnNames
specialMaxScan
private boolean specialMaxScan
distinctScan
private boolean distinctScan
raDependentScan
private boolean raDependentScan
- Information for dependent table scan for Referential Actions
raParentResultSetId
private java.lang.String raParentResultSetId
fkIndexConglomId
private long fkIndexConglomId
fkColArray
private int[] fkColArray
baseTableRestrictionList
PredicateList baseTableRestrictionList
- Restriction as a PredicateList
nonBaseTableRestrictionList
PredicateList nonBaseTableRestrictionList
restrictionList
PredicateList restrictionList
storeRestrictionList
PredicateList storeRestrictionList
nonStoreRestrictionList
PredicateList nonStoreRestrictionList
requalificationRestrictionList
PredicateList requalificationRestrictionList
UPDATE
public static final int UPDATE
- See Also:
- Constant Field Values
DELETE
public static final int DELETE
- See Also:
- Constant Field Values
existsBaseTable
private boolean existsBaseTable
isNotExists
private boolean isNotExists
dependencyMap
private org.apache.derby.iapi.util.JBitSet dependencyMap
getUpdateLocks
private boolean getUpdateLocks
gotRowCount
private boolean gotRowCount
rowCount
private long rowCount
| Constructor Detail |
FromBaseTable
public FromBaseTable()
| Method Detail |
init
public void init(java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
- Initializer for a table in a FROM list.
- Overrides:
initin classQueryTreeNode
LOJ_reorderable
public boolean LOJ_reorderable(int numTables)
throws org.apache.derby.iapi.error.StandardException
- no LOJ reordering for base table.
- Overrides:
LOJ_reorderablein classFromTable
LOJgetReferencedTables
public org.apache.derby.iapi.util.JBitSet LOJgetReferencedTables(int numTables) throws org.apache.derby.iapi.error.StandardException
- Overrides:
LOJgetReferencedTablesin classResultSetNode
nextAccessPath
public boolean nextAccessPath(org.apache.derby.iapi.sql.compile.Optimizer optimizer, org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList, org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.Optimizable - Choose the next access path to evaluate for this Optimizable.
- Specified by:
nextAccessPathin interfaceorg.apache.derby.iapi.sql.compile.Optimizable- Overrides:
nextAccessPathin classFromTable
canBeOrdered
protected boolean canBeOrdered()
- Tell super-class that this Optimizable can be ordered
- Overrides:
canBeOrderedin classFromTable
optimizeIt
public org.apache.derby.iapi.sql.compile.CostEstimate optimizeIt(org.apache.derby.iapi.sql.compile.Optimizer optimizer, org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList, org.apache.derby.iapi.sql.compile.CostEstimate outerCost, org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.Optimizable - Choose the best access path for this Optimizable.
- Specified by:
optimizeItin interfaceorg.apache.derby.iapi.sql.compile.Optimizable- Overrides:
optimizeItin classFromTable
getTableDescriptor
public org.apache.derby.iapi.sql.dictionary.TableDescriptor getTableDescriptor()
- Description copied from interface:
org.apache.derby.iapi.sql.compile.Optimizable - Get the table descriptor for this table (if any). Only base tables
have table descriptors - for the rest of the optimizables, this
method returns null.
- Specified by:
getTableDescriptorin interfaceorg.apache.derby.iapi.sql.compile.Optimizable- Overrides:
getTableDescriptorin classFromTable
isMaterializable
public boolean isMaterializable()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.Optimizable - Tell whether this Optimizable is materializable
- Specified by:
isMaterializablein interfaceorg.apache.derby.iapi.sql.compile.Optimizable- Overrides:
isMaterializablein classFromTable
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:
pushOptPredicatein interfaceorg.apache.derby.iapi.sql.compile.Optimizable- Overrides:
pushOptPredicatein classFromTable
pullOptPredicates
public void pullOptPredicates(org.apache.derby.iapi.sql.compile.OptimizablePredicateList optimizablePredicates) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.Optimizable - Pull all the OptimizablePredicates from this Optimizable and put them
in the given OptimizablePredicateList.
- Specified by:
pullOptPredicatesin interfaceorg.apache.derby.iapi.sql.compile.Optimizable- Overrides:
pullOptPredicatesin classFromTable
isCoveringIndex
public boolean isCoveringIndex(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
org.apache.derby.iapi.sql.compile.Optimizable - Return whether or not this is a covering index. We expect to call this
during generation, after access path selection is complete.
- Specified by:
isCoveringIndexin interfaceorg.apache.derby.
JAVADOC