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

public Class IntersectOrExceptNode

extends SetOperatorNode
Class Inheritance
Imports
java.sql.Types, java.util.BitSet, .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, .OptimizablePredicateList, .Optimizer, .RowOrdering, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, org.apache.derby.iapi.types.TypeId, org.apache.derby.iapi.util.JBitSet

A IntersectOrExceptNode represents an INTERSECT or EXCEPT DML statement.

Field Summary

Modifier and TypeField and Description
private boolean
public static final int
private int[]
private int[]
private boolean[]
public static final int
private int
Inherited from org.apache.derby.impl.sql.compile.SetOperatorNode:
allqec

Constructor Summary

AccessConstructor and Description
pack-priv
IntersectOrExceptNode(int
The operator type: one of EXCEPT_OP or INTERSECT_OP.
opType
,
ResultSetNode
The ResultSetNode on the left side of this union
leftResult
,
ResultSetNode
The ResultSetNode on the right side of this union
rightResult
,
boolean
true if this is an ALL set operation.
all
,
Properties
Properties list associated with the table
tableProperties
,
ContextManager
The context manager
cm
)

Constructor for a SetOperatorNode.

Method Summary

Modifier and TypeMethod and Description
private ResultSetNode

Returns:

(Potentially new) head of the ResultSetNode tree.
addNewNodes
()

Add any new ResultSetNodes that are necessary to the tree.

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

pack-priv CostEstimate

Returns:

The final CostEstimate for this IntersectOrExceptNode, which is the sum of the two child costs. The final number of rows depends on whether this is an INTERSECT or EXCEPT (see getRowCountEstimate() in this class for more).
getFinalCostEstimate
()

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

Get the final CostEstimate for this FromTable.

pack-priv String
private int
pack-priv double
getRowCountEstimate(double leftRowCount, double rightRowCount)

pack-priv double
getSingleScanRowCountEstimate(double leftSingleScanRowCount, double rightSingleScanRowCount)

public Optimizable
modifyAccessPath(JBitSet
Bit map of the tables that are outer to this one in the join order.
outerTables
)

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.modifyAccessPath.

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

Modify the access path for this Optimizable, as necessary.

pack-priv ResultSetNode
modifyAccessPaths()

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.modifyAccessPaths.

Modify the access paths according to the decisions the optimizer made.

pack-priv ResultSetNode

Returns:

The preprocessed ResultSetNode that can be optimized
preprocess
(int
Number of tables in the DML Statement
numTables
,
GroupByList
The group by list, if any
gbl
,
FromList
The from list, if any
fromList
)

Overrides org.apache.derby.impl.sql.compile.SetOperatorNode.preprocess.

Push order by lists down to the children so that we can implement the intersect/except by scan of the two sorted inputs.

private void
Inherited from org.apache.derby.impl.sql.compile.SetOperatorNode:
bindExpressionsbindResultColumnsbindResultColumnsbindTargetExpressionsbindUntypedNullsToResultColumnsensurePredicateListflattenableInFromSubquerygetFromTableByNamegetLeftOptPredicateListgetParamColumnTypesgetRightOptPredicateListhasUnPushedPredicatesmodifyAccessPathperformMaterializationprintSubNodespullOptPredicatespushOffsetFetchFirstpushOptPredicatepushOrderByListpushQueryExpressionSuffixreplaceOrForbidDefaultssetParamColumnTypessetResultToBooleanTrueNodetoStringverifySelectStarSubquery

Field Detail

addNewNodesCalledback to summary
private boolean addNewNodesCalled
EXCEPT_OPback to summary
public static final int EXCEPT_OP
intermediateOrderByColumnsback to summary
private int[] intermediateOrderByColumns
intermediateOrderByDirectionback to summary
private int[] intermediateOrderByDirection
intermediateOrderByNullsLowback to summary
private boolean[] intermediateOrderByNullsLow
INTERSECT_OPback to summary
public static final int INTERSECT_OP
opTypeback to summary
private int opType

Constructor Detail

IntersectOrExceptNodeback to summary
pack-priv IntersectOrExceptNode(int opType, ResultSetNode leftResult, ResultSetNode rightResult, boolean all, Properties tableProperties, ContextManager cm) throws StandardException

Constructor for a SetOperatorNode.

Parameters
opType:int

The operator type: one of EXCEPT_OP or INTERSECT_OP.

leftResult:ResultSetNode

The ResultSetNode on the left side of this union

rightResult:ResultSetNode

The ResultSetNode on the right side of this union

all:boolean

true if this is an ALL set operation.

tableProperties:Properties

Properties list associated with the table

cm:ContextManager

The context manager

Exceptions
StandardException:
Thrown on error

Method Detail

addNewNodesback to summary
private ResultSetNode addNewNodes() throws StandardException

Add any new ResultSetNodes that are necessary to the tree. We wait until after optimization to do this in order to make it easier on the optimizer.

Returns:ResultSetNode

(Potentially new) head of the ResultSetNode tree.

Exceptions
StandardException:
Thrown on error
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:

Doc from org.apache.derby.impl.sql.compile.FromTable.estimateCost.

Thrown on error

See Also
org.apache.derby.iapi.sql.compile.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 code.

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
getFinalCostEstimateback to summary
pack-priv CostEstimate getFinalCostEstimate() throws StandardException

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

Doc from org.apache.derby.impl.sql.compile.FromTable.getFinalCostEstimate.

Get the final CostEstimate for this FromTable.

Returns:CostEstimate

The final CostEstimate for this IntersectOrExceptNode, which is the sum of the two child costs. The final number of rows depends on whether this is an INTERSECT or EXCEPT (see getRowCountEstimate() in this class for more).

Annotations
@Override
See Also
Get the final CostEstimate for this IntersectOrExceptNode.
getOperatorNameback to summary
pack-priv String getOperatorName()

Implements abstract org.apache.derby.impl.sql.compile.SetOperatorNode.getOperatorName.

Returns:String

Doc from org.apache.derby.impl.sql.compile.SetOperatorNode.getOperatorName.

the operator name: "UNION", "INTERSECT", or "EXCEPT"

getOpTypeback to summary
private int getOpType()
getRowCountEstimateback to summary
pack-priv double getRowCountEstimate(double leftRowCount, double rightRowCount)
getSingleScanRowCountEstimateback to summary
pack-priv double getSingleScanRowCountEstimate(double leftSingleScanRowCount, double rightSingleScanRowCount)
modifyAccessPathback to summary
public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.modifyAccessPath.

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

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

Modify the access path for this Optimizable, as necessary. This includes things like adding a result set to translate from index rows to base rows

Parameters
outerTables:JBitSet

Bit map of the tables that are outer to this one in the join order.

Returns:Optimizable

The (potentially new) Optimizable at the top of the tree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#modifyAccessPath
modifyAccessPathsback to summary
pack-priv ResultSetNode modifyAccessPaths() throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.modifyAccessPaths.

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.modifyAccessPaths.

Modify the access paths according to the decisions the optimizer made. This can include adding project/restrict nodes, index-to-base-row nodes, etc.

Returns:ResultSetNode

The modified query tree

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
ResultSetNode#modifyAccessPaths
preprocessback to summary
pack-priv ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException

Overrides org.apache.derby.impl.sql.compile.SetOperatorNode.preprocess.

Push order by lists down to the children so that we can implement the intersect/except by scan of the two sorted inputs.

Parameters
numTables:int

Number of tables in the DML Statement

gbl:GroupByList

The group by list, if any

fromList:FromList

The from list, if any

Returns:ResultSetNode

The preprocessed ResultSetNode that can be optimized

Annotations
@Override
Exceptions
StandardException:
Thrown on error
pushOrderingDownback to summary
private void pushOrderingDown(ResultSetNode rsn) throws StandardException