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

pack-priv Class DistinctNode

extends SingleChildResultSetNode
Class Inheritance
Imports
java.util.List, .Properties, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CostEstimate, .Optimizable, .OptimizablePredicate, .OptimizablePredicateList, .Optimizer, .RequiredRowOrdering, .RowOrdering, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, .DataDictionary

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.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
Inherited from org.apache.derby.impl.sql.compile.SingleChildResultSetNode:
childResulthasTrulyTheBestAccessPath

Constructor Summary

AccessConstructor and Description
pack-priv
DistinctNode(ResultSetNode
The child ResultSetNode
childResult
,
boolean
Whether or not the child ResultSetNode returns its output in sorted order.
inSortedOrder
,
Properties
Properties list associated with the table
tableProperties
,
ContextManager
The context manager
cm
)

Constructor for a DistinctNode.

Method Summary

Modifier and TypeMethod and Description
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.

pack-priv void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The method for the generated code to go into
mb
)

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

generate the distinct result set operating over the source result set.

pack-priv boolean

Returns:

Whether the underlying ResultSet tree is ordered on the specified column.
isOrderedOn
(ColumnReference[]
The specified ColumnReference[]
crs
,
boolean
Whether or not the order of the CRs in the array can be permuted
permuteOrdering
,
List<FromBaseTable>
List that is to be filled with the FromBaseTable
fbtHolder
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.isOrderedOn.

Return whether or not the underlying ResultSet tree is ordered on the specified columns.

pack-priv ResultSetNode

Returns:

ResultSetNode The top of the optimized subtree
optimize
(DataDictionary
The DataDictionary to use for optimization
dataDictionary
,
PredicateList
The PredicateList to optimize. This should be a join predicate.
predicates
,
double
The number of outer joining rows
outerRows
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.optimize.

Optimize this DistinctNode.

public CostEstimate
optimizeIt(Optimizer
Optimizer to use.
optimizer
,
OptimizablePredicateList
The predicate list to optimize against
predList
,
CostEstimate
The CostEstimate for the outer tables in the join order, telling how many times this Optimizable will be scanned.
outerCost
,
RowOrdering
The row ordering for all the tables in the join order, including this one.
rowOrdering
)

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

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

Choose the best access path for this Optimizable.

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.

Inherited from org.apache.derby.impl.sql.compile.SingleChildResultSetNode:
acceptChildrenaddNewPredicateadjustForSortEliminationadjustForSortEliminationchangeAccessPathdecrementLevelensurePredicateListflattenableInFromSubqueryforUpdategetChildResultgetFinalCostEstimategetFromTableByNamegetTrulyTheBestAccessPathinitAccessPathsisNotExistsisOneRowResultSetmodifyAccessPathspreprocessprintSubNodespullOptPredicatespushExpressionsreferencesSessionSchemareferencesTargetreflectionNeededForProjectionsetChildResultsetLevelsubqueryReferencesTargetupdateBestPlanMapupdateTargetLockMode

Field Detail

inSortedOrderback to summary
pack-priv boolean inSortedOrder

Constructor Detail

DistinctNodeback to summary
pack-priv DistinctNode(ResultSetNode childResult, boolean inSortedOrder, Properties tableProperties, ContextManager cm) throws StandardException

Constructor for a DistinctNode.

Parameters
childResult:ResultSetNode

The child ResultSetNode

inSortedOrder:boolean

Whether or not the child ResultSetNode returns its output in sorted order.

tableProperties:Properties

Properties list associated with the table

cm:ContextManager

The context manager

Exceptions
StandardException:
Thrown on error

Method Detail

estimateCostback to summary
public CostEstimate estimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) throws StandardException

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.estimateCost.

Estimate 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.

Parameters
predList:OptimizablePredicateList

The predicate list to optimize against

cd:ConglomerateDescriptor

The conglomerate descriptor to get the cost of

outerCost:CostEstimate

The estimated cost of the part of the plan outer to this optimizable.

optimizer:Optimizer

The optimizer to use to help estimate the cost

rowOrdering:RowOrdering

The row ordering for all the tables in the join order, including this one.

Returns:CostEstimate

The estimated cost of doing the scan

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#estimateCost
generateback to summary
pack-priv void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException

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

generate the distinct result set operating over the source result set.

Parameters
acb:ActivationClassBuilder

Doc from org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

The ActivationClassBuilder for the class being built

mb:MethodBuilder

Doc from org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

The method for the generated code to go into

Annotations
@Override
Exceptions
StandardException:
Thrown on error
isOrderedOnback to summary
pack-priv boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, List<FromBaseTable> fbtHolder)

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

Parameters
crs:ColumnReference[]

The specified ColumnReference[]

permuteOrdering:boolean

Whether or not the order of the CRs in the array can be permuted

fbtHolder:List<FromBaseTable>

List that is to be filled with the FromBaseTable

Returns:boolean

Whether the underlying ResultSet tree is ordered on the specified column.

Annotations
@Override
optimizeback to summary
pack-priv ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.optimize.

Optimize this DistinctNode.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use for optimization

predicates:PredicateList

The PredicateList to optimize. This should be a join predicate.

outerRows:double

The number of outer joining rows

Returns:ResultSetNode

ResultSetNode The top of the optimized subtree

Annotations
@Override
Exceptions
StandardException:
Thrown on error
optimizeItback to summary
public CostEstimate optimizeIt(Optimizer optimizer, OptimizablePredicateList predList, CostEstimate outerCost, RowOrdering rowOrdering) throws StandardException

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.optimizeIt.

Choose the best access path for this Optimizable.

Parameters
optimizer:Optimizer

Optimizer to use.

predList:OptimizablePredicateList

The predicate list to optimize against

outerCost:CostEstimate

The CostEstimate for the outer tables in the join order, telling how many times this Optimizable will be scanned.

rowOrdering:RowOrdering

The row ordering for all the tables in the join order, including this one.

Returns:CostEstimate

The optimizer's estimated cost of the best access path.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#optimizeIt
pushOptPredicateback to summary
public boolean pushOptPredicate(OptimizablePredicate optimizablePredicate) throws StandardException

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.pushOptPredicate.

Push an OptimizablePredicate down, if this node accepts it.

Parameters
optimizablePredicate:OptimizablePredicate

OptimizablePredicate to push down.

Returns:boolean

Whether or not the predicate was pushed down.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
org.apache.derby.iapi.sql.compile.Optimizable#pushOptPredicate