📄 resultsetnode.java
字号:
throws StandardException { return false; } /** * Return whether or not this ResultSetNode contains a subquery with a * reference to the specified target. * * @param name The table name. * * @return boolean Whether or not a reference to the table was found. * * @exception StandardException Thrown on error */ boolean subqueryReferencesTarget(String name, boolean baseTable) throws StandardException { return false; } /** * 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 false; } /** * Return whether or not the underlying ResultSet tree is for a NOT EXISTS * join. * * @return Whether or not the underlying ResultSet tree if for NOT EXISTS. */ public boolean isNotExists() { // Default is false return false; } /** * Get an optimizer to use for this ResultSetNode. Only get it once - * subsequent calls return the same optimizer. * * @exception StandardException Thrown on error */ protected Optimizer getOptimizer( OptimizableList optList, OptimizablePredicateList predList, DataDictionary dataDictionary, RequiredRowOrdering requiredRowOrdering) throws StandardException { if (optimizer == null) { /* Get an optimizer. */ OptimizerFactory optimizerFactory = getLanguageConnectionContext().getOptimizerFactory(); optimizer = optimizerFactory.getOptimizer( optList, predList, dataDictionary, requiredRowOrdering, getCompilerContext().getNumTables(), getLanguageConnectionContext()); } optimizer.prepForNextRound(); return optimizer; } /** * Get the optimizer for this result set. * * @return If this.optimizer has has already been created by the * getOptimizer() method above, then return it; otherwise, * return null. */ protected OptimizerImpl getOptimizerImpl() { // Note that the optimizer might be null because it's possible that // we'll get here before any calls to getOptimizer() were made, which // can happen if we're trying to save a "best path" but we haven't // actually found one yet. In that case we just return the "null" // value; the caller must check for it and behave appropriately. // Ex. see TableOperatorNode.addOrLoadBestPlanMapping(). return (OptimizerImpl)optimizer; } /** * Get a cost estimate to use for this ResultSetNode. * * @exception StandardException Thrown on error */ protected CostEstimate getNewCostEstimate() throws StandardException { OptimizerFactory optimizerFactory = getLanguageConnectionContext().getOptimizerFactory(); return optimizerFactory.getCostEstimate(); } /** * 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 { Visitable returnNode = v.visit(this); if (v.skipChildren(this)) { return returnNode; } if (resultColumns != null && !v.stopTraversal()) { resultColumns = (ResultColumnList)resultColumns.accept(v); } return returnNode; } /** * Consider materialization for this ResultSet tree if it is valid and cost effective * (It is not valid if incorrect results would be returned.) * * @return Top of the new/same ResultSet tree. * * @exception StandardException Thrown on error */ public ResultSetNode considerMaterialization(JBitSet outerTables) throws StandardException { return this; } /** * Return whether or not to materialize this ResultSet tree. * * @return Whether or not to materialize this ResultSet tree. * would return valid results. * * @exception StandardException Thrown on error */ public boolean performMaterialization(JBitSet outerTables) throws StandardException { return false; } /** * 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 { if (SanityManager.DEBUG) { SanityManager.THROWASSERT("getFromTableByName() not expected to be called for " + getClass().getName()); } return null; } /** * Decrement (query block) level (0-based) for * all of the tables in this ResultSet tree. * This is useful when flattening a subquery. * * @param decrement The amount to decrement by. * * @return Nothing; */ abstract void decrementLevel(int decrement); /** * Push the order by list down from the cursor node * into its child result set so that the optimizer * has all of the information that it needs to * consider sort avoidance. * * @param orderByList The order by list * * @return Nothing. */ void pushOrderByList(OrderByList orderByList) { if (SanityManager.DEBUG) { SanityManager.THROWASSERT("pushOrderByList() not expected to be called for " + getClass().getName()); } } /** * General logic shared by Core compilation and by the Replication Filter * compiler. A couple ResultSets (the ones used by PREPARE SELECT FILTER) * implement this method. * * @param ecb The ExpressionClassBuilder for the class being built * @param eb The method the expression will go into * * * @exception StandardException Thrown on error */ public void generateResultSet(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException { System.out.println("I am a " + getClass()); if (SanityManager.DEBUG) SanityManager.NOTREACHED(); return; } /** * 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. * * @see TransactionController * * @return The lock mode */ public int updateTargetLockMode() { return TransactionController.MODE_TABLE; } /** * Mark this node and its children as not being a flattenable join. * * @return Nothing. */ void notFlattenableJoin() { } /** * 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 false; } /** * Return whether or not this ResultSet tree is guaranteed to return * at most 1 row based on heuristics. (A RowResultSetNode and a * SELECT with a non-grouped aggregate will return at most 1 row.) * * @return Whether or not this ResultSet tree is guaranteed to return * at most 1 row based on heuristics. */ boolean returnsAtMostOneRow() { return false; } /** * 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 { // Only subclasses with something to do override this. } /** * Is it possible to do a distinct scan on this ResultSet tree. * (See SelectNode for the criteria.) * * @param distinctColumns the set of distinct columns * @return Whether or not it is possible to do a distinct scan on this ResultSet tree. */ boolean isPossibleDistinctScan(Set distinctColumns) { return false; } /** * Mark the underlying scan as a distinct scan. * * @return Nothing. */ void markForDistinctScan() { if (SanityManager.DEBUG) { SanityManager.THROWASSERT( "markForDistinctScan() not expected to be called for " + getClass().getName()); } } /** * 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() { if (SanityManager.DEBUG) { SanityManager.THROWASSERT( "markOrderingDependent() not expected to be called for " + getClass().getName()); } } /** * Count the number of distinct aggregates in the list. * By 'distinct' we mean aggregates of the form: * <UL><I>SELECT MAX(DISTINCT x) FROM T<\I><\UL> * * @return number of aggregates */ protected static final int numDistinctAggregates(Vector aggregateVector) { int count = 0; int size = aggregateVector.size(); for (int index = 0; index < size; index++) { count += (((AggregateNode) aggregateVector.elementAt(index)).isDistinct() == true) ? 1 : 0; } return count; } // It may be we have a SELECT view underneath a LOJ. // Return null for now.. we don't do any optimization. public JBitSet LOJgetReferencedTables(int numTables) throws StandardException { if (this instanceof FromTable) { if (((FromTable)this).tableNumber != -1) { JBitSet map = new JBitSet(numTables); map.set(((FromTable)this).tableNumber); return map; } } return null; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -