📄 singlechildresultsetnode.java
字号:
/** * Add a new predicate to the list. This is useful when doing subquery * transformations, when we build a new predicate with the left side of * the subquery operator and the subquery's result column. * * @param predicate The predicate to add * * @return ResultSetNode The new top of the tree. * * @exception StandardException Thrown on error */ public ResultSetNode addNewPredicate(Predicate predicate) throws StandardException { childResult = childResult.addNewPredicate(predicate); return this; } /** * 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. * * @param predicateList The PredicateList. * * @exception StandardException Thrown on error */ public void pushExpressions(PredicateList predicateList) throws StandardException { if (childResult instanceof FromTable) { ((FromTable) childResult).pushExpressions(predicateList); } } /** * Evaluate whether or not the subquery in a FromSubquery is flattenable. * Currently, a FSqry is flattenable if all of the following are true: * o Subquery is a SelectNode. * o It contains no top level subqueries. (RESOLVE - we can relax this) * o It does not contain a group by or having clause * o It does not contain aggregates. * * @param fromList The outer from list * * @return boolean Whether or not the FromSubquery is flattenable. */ public boolean flattenableInFromSubquery(FromList fromList) { /* Flattening currently involves merging predicates and FromLists. * We don't have a FromList, so we can't flatten for now. */ /* RESOLVE - this will introduce yet another unnecessary PRN */ return false; } /** * Ensure that the top of the RSN tree has a PredicateList. * * @param numTables The number of tables in the query. * @return ResultSetNode A RSN tree with a node which has a PredicateList on top. * * @exception StandardException Thrown on error */ public ResultSetNode ensurePredicateList(int numTables) throws StandardException { return this; } /** * Optimize this SingleChildResultSetNode. * * @param dataDictionary The DataDictionary to use for optimization * @param predicateList The PredicateList to optimize. This should * be a join predicate. * @param outerRows The number of outer joining rows * * @return ResultSetNode The top of the optimized subtree * * @exception StandardException Thrown on error */ public ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException { /* We need to implement this method since a NRSN can appear above a * SelectNode in a query tree. */ childResult = childResult.optimize( dataDictionary, predicates, outerRows); Optimizer optimizer = getOptimizer( (FromList) getNodeFactory().getNode( C_NodeTypes.FROM_LIST, getNodeFactory().doJoinOrderOptimization(), getContextManager()), predicates, dataDictionary, (RequiredRowOrdering) null); costEstimate = optimizer.newCostEstimate(); costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(), childResult.getCostEstimate().rowCount(), childResult.getCostEstimate().singleScanRowCount()); return this; } /** * @see ResultSetNode#modifyAccessPaths * * @exception StandardException Thrown on error */ public ResultSetNode modifyAccessPaths() throws StandardException { childResult = childResult.modifyAccessPaths(); return this; } /** * @see ResultSetNode#changeAccessPath * * @exception StandardException Thrown on error */ public ResultSetNode changeAccessPath() throws StandardException { childResult = childResult.changeAccessPath(); return this; } /** * Determine whether or not the specified name is an exposed name in * the current query block. * * @param name The specified name to search for as an exposed name. * @param schemaName Schema name, if non-null. * @param exactMatch Whether or not we need an exact match on specified schema and table * names or match on table id. * * @return The FromTable, if any, with the exposed name. * * @exception StandardException Thrown on error */ protected FromTable getFromTableByName(String name, String schemaName, boolean exactMatch) throws StandardException { return childResult.getFromTableByName(name, schemaName, exactMatch); } /** * Decrement (query block) level (0-based) for this FromTable. * This is useful when flattening a subquery. * * @param decrement The amount to decrement by. */ void decrementLevel(int decrement) { super.decrementLevel(decrement); childResult.decrementLevel(decrement); } /** * Get the lock mode for the target of an update statement * (a delete or update). The update mode will always be row for * CurrentOfNodes. It will be table if there is no where clause. * * @return The lock mode */ public int updateTargetLockMode() { return childResult.updateTargetLockMode(); } /** * Return whether or not the underlying ResultSet tree * is ordered on the specified columns. * RESOLVE - This method currently only considers the outermost table * of the query block. * * @param crs The specified ColumnReference[] * @param permuteOrdering Whether or not the order of the CRs in the array can be permuted * @param fbtVector Vector that is to be filled with the FromBaseTable * * @return Whether the underlying ResultSet tree * is ordered on the specified column. * * @exception StandardException Thrown on error */ boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, Vector fbtVector) throws StandardException { return childResult.isOrderedOn(crs, permuteOrdering, fbtVector); } /** * Return whether or not the underlying ResultSet tree will return * a single row, at most. * This is important for join nodes where we can save the extra next * on the right side if we know that it will return at most 1 row. * * @return Whether or not the underlying ResultSet tree will return a single row. * @exception StandardException Thrown on error */ public boolean isOneRowResultSet() throws StandardException { // Default is false return childResult.isOneRowResultSet(); } /** * Return whether or not the underlying ResultSet tree is for a NOT EXISTS join. * * @return Whether or not the underlying ResultSet tree is for a NOT EXISTS. */ public boolean isNotExists() { return childResult.isNotExists(); } /** * Determine whether we need to do reflection in order to do the projection. * Reflection is only needed if there is at least 1 column which is not * simply selecting the source column. * * @return Whether or not we need to do reflection in order to do * the projection. */ protected boolean reflectionNeededForProjection() { return ! (resultColumns.allExpressionsAreColumns(childResult)); } /** * Replace any DEFAULTs with the associated tree for the default. * * @param ttd The TableDescriptor for the target table. * @param tcl The RCL for the target table. * * @exception StandardException Thrown on error */ void replaceDefaults(TableDescriptor ttd, ResultColumnList tcl) throws StandardException { childResult.replaceDefaults(ttd, tcl); } /** * Notify the underlying result set tree that the result is * ordering dependent. (For example, no bulk fetch on an index * if under an IndexRowToBaseRow.) * * @return Nothing. */ void markOrderingDependent() { childResult.markOrderingDependent(); } /** * Get the final CostEstimate for this node. * * @return The final CostEstimate for this node, which is * the final cost estimate for the child node. */ public CostEstimate getFinalCostEstimate() throws StandardException { /* ** The cost estimate will be set here if either optimize() or ** optimizeIt() was called on this node. It's also possible ** that optimization was done directly on the child node, ** in which case the cost estimate will be null here. */ if (costEstimate == null) return childResult.getFinalCostEstimate(); else { return costEstimate; } } /** * Accept a visitor, and call v.visit() * on child nodes as necessary. * * @param v the visitor * * @exception StandardException on error */ public Visitable accept(Visitor v) throws StandardException { if (v.skipChildren(this)) { return v.visit(this); } Visitable returnNode = super.accept(v); if (childResult != null && !v.stopTraversal()) { childResult = (ResultSetNode)childResult.accept(v); } return returnNode; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -