Class DistinctNode
java.lang.Object
org.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.SingleChildResultSetNode
org.apache.derby.impl.sql.compile.DistinctNode
- All Implemented Interfaces:
Optimizable, Visitable
A DistinctNode represents a result set for a distinct operation
on a select. It has the same description as its input result set.
For the most part, it simply delegates operations to its childResultSet,
which is currently expected to be a ProjectRestrictResultSet generated
for a SelectNode.
NOTE: A DistinctNode extends FromTable since it can exist in a FromList.
-
Nested Class Summary
Nested classes/interfaces inherited from class ResultSetNode
ResultSetNode.QueryExpressionClauses -
Field Summary
FieldsFields inherited from class SingleChildResultSetNode
childResult, hasTrulyTheBestAccessPathFields inherited from class FromTable
ADD_PLAN, bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, LOAD_PLAN, loadFactor, maxCapacity, origTableName, REMOVE_PLAN, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategyFields inherited from class QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX -
Constructor Summary
ConstructorsConstructorDescriptionDistinctNode(ResultSetNode childResult, boolean inSortedOrder, Properties tableProperties, ContextManager cm) Constructor for a DistinctNode. -
Method Summary
Modifier and TypeMethodDescriptionestimateCost(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.(package private) voidgenerate(ActivationClassBuilder acb, MethodBuilder mb) generate the distinct result set operating over the source result set.(package private) booleanisOrderedOn(ColumnReference[] crs, boolean permuteOrdering, List<FromBaseTable> fbtHolder) Return whether or not the underlying ResultSet tree is ordered on the specified columns.(package private) ResultSetNodeoptimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) Optimize this DistinctNode.optimizeIt(Optimizer optimizer, OptimizablePredicateList predList, CostEstimate outerCost, RowOrdering rowOrdering) Choose the best access path for this Optimizable.booleanpushOptPredicate(OptimizablePredicate optimizablePredicate) Push an OptimizablePredicate down, if this node accepts it.Methods inherited from class SingleChildResultSetNode
acceptChildren, addNewPredicate, adjustForSortElimination, adjustForSortElimination, changeAccessPath, decrementLevel, ensurePredicateList, flattenableInFromSubquery, forUpdate, getChildResult, getFinalCostEstimate, getFromTableByName, getTrulyTheBestAccessPath, initAccessPaths, isNotExists, isOneRowResultSet, modifyAccessPaths, preprocess, printSubNodes, pullOptPredicates, pushExpressions, referencesSessionSchema, referencesTarget, reflectionNeededForProjection, setChildResult, setLevel, subqueryReferencesTarget, updateBestPlanMap, updateTargetLockModeMethods inherited from class FromTable
assignCostEstimate, canBeOrdered, columnsAreUpdatable, considerSortAvoidancePath, convertAbsoluteToRelativeColumnPosition, cursorTargetTable, feasibleJoinStrategy, fillInReferencedTableMap, flatten, getBaseTableName, getBestAccessPath, getBestSortAvoidancePath, getCorrelationName, getCostEstimate, getCurrentAccessPath, getExposedName, getLevel, getMergeTableID, getName, getNumColumnsReturned, getOrigTableName, getProperties, getResultColumnsForList, getSchemaDescriptor, getSchemaDescriptor, getScratchCostEstimate, getTableDescriptor, getTableName, getTableNumber, getUserSpecifiedJoinStrategy, hashKeyColumns, hasLargeObjectColumns, hasTableNumber, initialCapacity, isBaseTable, isCoveringIndex, isFlattenableJoinNode, isJoinColumnForRightOuterJoin, isMaterializable, isOneRowScan, isTargetTable, legalJoinOrder, loadFactor, LOJ_reorderable, markUpdatableByCursor, maxCapacity, memoryUsageOK, modifyAccessPath, needsSpecialRCLBinding, nextAccessPath, optimizeSubqueries, rememberAsBest, rememberJoinStrategyAsBest, rememberSortAvoidancePath, resetJoinStrategies, setCostEstimateCost, setHashKeyColumns, setMergeTableID, setOrigTableName, setProperties, setTableNumber, startOptimizing, supportsMultipleInstantiations, tellRowOrderingAboutConstantColumns, toString, transformOuterJoins, uniqueJoin, verifyPropertiesMethods inherited from class ResultSetNode
assignResultSetNumber, bindExpressions, bindExpressionsWithTables, bindNonVTITables, bindResultColumns, bindResultColumns, bindTargetExpressions, bindUntypedNullsToResultColumns, bindVTITables, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, generateNormalizationResultSet, generateResultSet, genProjectRestrict, genProjectRestrict, genProjectRestrictForReordering, getAllResultColumns, getCandidateFinalCostEstimate, getCostEstimate, getCursorTargetTable, getFromList, getMatchingColumn, getNewCostEstimate, getOptimizer, getOptimizerImpl, getRCLForInsert, getReferencedTableMap, getResultColumns, getResultSetNumber, getScratchCostEstimate, isCursorTargetTable, isInsertSource, isPossibleDistinctScan, isStatementResultSet, isUpdatableCursor, LOJgetReferencedTables, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markStatementResultSet, modifyAccessPaths, notCursorTargetTable, notFlattenableJoin, numDistinctAggregates, parseDefault, performMaterialization, printQueryExpressionSuffixClauses, projectResultColumns, pushOffsetFetchFirst, pushOrderByList, pushQueryExpressionSuffix, rejectParameters, rejectXMLValues, renameGeneratedResultNames, replaceOrForbidDefaults, returnsAtMostOneRow, setCandidateFinalCostEstimate, setCostEstimate, setCursorTargetTable, setInsertSource, setOptimizer, setReferencedTableMap, setResultColumns, setResultSetNumber, setResultToBooleanTrueNode, setScratchCostEstimate, setTableConstructorTypes, verifySelectStarSubqueryMethods inherited from class QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExistMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Optimizable
getDataDictionary, getOptimizerTracer, getReferencedTableMap, getResultSetNumber, optimizerTracingIsOnMethods inherited from interface Visitable
accept, addTag, taggedWith
-
Field Details
-
inSortedOrder
boolean inSortedOrder
-
-
Constructor Details
-
DistinctNode
DistinctNode(ResultSetNode childResult, boolean inSortedOrder, Properties tableProperties, ContextManager cm) throws StandardException Constructor for a DistinctNode.- Parameters:
childResult- The child ResultSetNodeinSortedOrder- Whether or not the child ResultSetNode returns its output in sorted order.tableProperties- Properties list associated with the tablecm- The context manager- Throws:
StandardException- Thrown on error
-
-
Method Details
-
optimizeIt
public CostEstimate optimizeIt(Optimizer optimizer, OptimizablePredicateList predList, CostEstimate outerCost, RowOrdering rowOrdering) throws StandardException Description copied from interface:OptimizableChoose the best access path for this Optimizable.- Specified by:
optimizeItin interfaceOptimizable- Overrides:
optimizeItin classFromTable- Parameters:
optimizer- Optimizer to use.predList- The predicate list to optimize againstouterCost- The CostEstimate for the outer tables in the join order, telling how many times this Optimizable will be scanned.rowOrdering- The row ordering for all the tables in the join order, including this one.- Returns:
- The optimizer's estimated cost of the best access path.
- Throws:
StandardException- Thrown on error- See Also:
-
estimateCost
public CostEstimate estimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) throws StandardException Description copied from interface:OptimizableEstimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate. It is assumed that the predicate list has already been classified. This cost estimate is just for one scan, not for the life of the query.- Specified by:
estimateCostin interfaceOptimizable- Overrides:
estimateCostin classFromTable- Parameters:
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.- Returns:
- The estimated cost of doing the scan
- Throws:
StandardException- Thrown on error- See Also:
-
pushOptPredicate
Description copied from interface:OptimizablePush an OptimizablePredicate down, if this node accepts it.- Specified by:
pushOptPredicatein interfaceOptimizable- Overrides:
pushOptPredicatein classFromTable- Parameters:
optimizablePredicate- OptimizablePredicate to push down.- Returns:
- Whether or not the predicate was pushed down.
- Throws:
StandardException- Thrown on error- See Also:
-
optimize
ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException Optimize this DistinctNode.- Overrides:
optimizein classSingleChildResultSetNode- Parameters:
dataDictionary- The DataDictionary to use for optimizationpredicates- The PredicateList to optimize. This should be a join predicate.outerRows- The number of outer joining rows- Returns:
- ResultSetNode The top of the optimized subtree
- Throws:
StandardException- Thrown on error
-
isOrderedOn
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.- Overrides:
isOrderedOnin classSingleChildResultSetNode- Parameters:
crs- The specified ColumnReference[]permuteOrdering- Whether or not the order of the CRs in the array can be permutedfbtHolder- List that is to be filled with the FromBaseTable- Returns:
- Whether the underlying ResultSet tree is ordered on the specified column.
-
generate
generate the distinct result set operating over the source result set.- Overrides:
generatein classQueryTreeNode- Parameters:
acb- The ActivationClassBuilder for the class being builtmb- The method for the generated code to go into- Throws:
StandardException- Thrown on error
-