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

public final Class InListOperatorNode

extends BinaryListOperatorNode
Class Inheritance
Imports
java.lang.reflect.Modifier, 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.LocalField, .MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.loader.ClassFactory, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, .TypeId

An InListOperatorNode represents an IN list.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
Inherited from org.apache.derby.impl.sql.compile.BinaryListOperatorNode:
leftOperandmethodNameoperatorrightOperandList

Constructor Summary

AccessConstructor and Description
pack-priv
InListOperatorNode(ValueNode
The left operand of the node
leftOperand
,
ValueNodeList
The right operand list of the node
rightOperandList
,
ContextManager
Context manager
cm
)

Method Summary

Modifier and TypeMethod and Description
pack-priv ValueNode

Returns:

The modified expression
eliminateNots
(boolean
Whether or not we are under a NotNode.
underNotNode
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.eliminateNots.

Eliminate NotNodes in the current query block.

pack-priv void
generateExpression(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
The MethodBuilder the expression will go into
mb
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.generateExpression.

Do code generation for this IN list operator.

protected LocalField
generateListAsArray(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
The MethodBuilder the expression will go into
mb
)

Generate the code to create an array of DataValueDescriptors that will hold the IN-list values at execution time.

pack-priv void
generateStartStopKey(boolean
is the index ascending on the column in question
isAsc
,
boolean
are we generating start key or not
isStartKey
,
ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
The MethodBuilder the expression will go into
mb
)

Generate start/stop key for this IN list operator.

private DataTypeDescriptor

Returns:

the type descriptor for the dominant type
getDominantType
()

Get the dominant type of all the operands in this IN list.

protected boolean
isOrdered()

Return whether or not the IN-list values for this node are ordered.

protected void
markAsOrdered()

Indicate that the IN-list values for this node are ordered (i.e. they are all constants and they have been sorted).

protected void
markSortDescending()

Indicate that the IN-list values for this node must be sorted in DESCENDING order.

pack-priv ValueNode

Returns:

The modified expression
preprocess
(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

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

Preprocess an expression tree.

public double
selectivity(Optimizable optTable)

Overrides org.apache.derby.impl.sql.compile.ValueNode.selectivity.

The selectivity for an "IN" predicate is generally very small.

pack-priv boolean

Returns:

true if in list references the same table as in cr.
selfReference
(ColumnReference
The column reference.
cr
)

See if this IN list operator is referencing the same table.

protected InListOperatorNode
shallowCopy()

Create a shallow copy of this InListOperatorNode whose operands are the same as this node's operands.

protected boolean
sortDescending()

Return whether or not the IN-list values for this node must be sorted in DESCENDING order.

public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.BinaryListOperatorNode.toString.

Convert this object to a String.

Inherited from org.apache.derby.impl.sql.compile.BinaryListOperatorNode:
acceptChildrenbindComparisonOperatorbindExpressioncategorizeconstantExpressiongetLeftOperandgetOrderableVariantTypegetRightOperandListisConstantExpressionisEquivalentprintSubNodesremapColumnReferencesToExpressionssetLeftOperandsetRightOperandList

Field Detail

isOrderedback to summary
private boolean isOrdered
sortDescendingback to summary
private boolean sortDescending

Constructor Detail

InListOperatorNodeback to summary
pack-priv InListOperatorNode(ValueNode leftOperand, ValueNodeList rightOperandList, ContextManager cm) throws StandardException
Parameters
leftOperand:ValueNode

The left operand of the node

rightOperandList:ValueNodeList

The right operand list of the node

cm:ContextManager

Context manager

Method Detail

eliminateNotsback to summary
pack-priv ValueNode eliminateNots(boolean underNotNode) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ValueNode.eliminateNots.

Eliminate NotNodes in the current query block. We traverse the tree, inverting ANDs and ORs and eliminating NOTs as we go. We stop at ComparisonOperators and boolean expressions. We invert ComparisonOperators and replace boolean expressions with boolean expression = false.

Note

Since we do not recurse under ComparisonOperators, there still could be NotNodes left in the tree.

Parameters
underNotNode:boolean

Whether or not we are under a NotNode.

Returns:ValueNode

The modified expression

Annotations
@Override
Exceptions
StandardException:
Thrown on error
generateExpressionback to summary
pack-priv void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ValueNode.generateExpression.

Do code generation for this IN list operator.

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

The MethodBuilder the expression will go into

Annotations
@Override
Exceptions
StandardException:
Thrown on error
generateListAsArrayback to summary
protected LocalField generateListAsArray(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Generate the code to create an array of DataValueDescriptors that will hold the IN-list values at execution time. The array gets created in the constructor. All constant elements in the array are initialized in the constructor. All non-constant elements, if any, are initialized each time the IN list is evaluated.

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

The MethodBuilder the expression will go into

generateStartStopKeyback to summary
pack-priv void generateStartStopKey(boolean isAsc, boolean isStartKey, ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Generate start/stop key for this IN list operator. Bug 3858.

Parameters
isAsc:boolean

is the index ascending on the column in question

isStartKey:boolean

are we generating start key or not

acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

The MethodBuilder the expression will go into

Exceptions
StandardException:
Thrown on error
getDominantTypeback to summary
private DataTypeDescriptor getDominantType()

Get the dominant type of all the operands in this IN list.

Returns:DataTypeDescriptor

the type descriptor for the dominant type

See Also
DataTypeDescriptor#getDominantType(DataTypeDescriptor, ClassFactory)
isOrderedback to summary
protected boolean isOrdered()

Return whether or not the IN-list values for this node are ordered. This is used for determining whether or not we need to do an execution- time sort.

markAsOrderedback to summary
protected void markAsOrdered()

Indicate that the IN-list values for this node are ordered (i.e. they are all constants and they have been sorted).

markSortDescendingback to summary
protected void markSortDescending()

Indicate that the IN-list values for this node must be sorted in DESCENDING order. This only applies to in-list "multi-probing", where the rows are processed in the order of the IN list elements themselves. In that case, any requirement to sort the rows in descending order means that the values in the IN list have to be sorted in descending order, as well.

preprocessback to summary
pack-priv ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException

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

Preprocess an expression tree. We do a number of transformations here (including subqueries, IN lists, LIKE and BETWEEN) plus subquery flattening.

Note

This is done before the outer ResultSetNode is preprocessed.

Parameters
numTables:int

Number of tables in the DML Statement

outerFromList:FromList

FromList from outer query block

outerSubqueryList:SubqueryList

SubqueryList from outer query block

outerPredicateList:PredicateList

PredicateList from outer query block

Returns:ValueNode

The modified expression

Annotations
@Override
Exceptions
StandardException:
Thrown on error
selectivityback to summary
public double selectivity(Optimizable optTable)

Overrides org.apache.derby.impl.sql.compile.ValueNode.selectivity.

The selectivity for an "IN" predicate is generally very small. This is an estimate applicable when in list are not all constants.

Annotations
@Override
selfReferenceback to summary
pack-priv boolean selfReference(ColumnReference cr) throws StandardException

See if this IN list operator is referencing the same table.

Parameters
cr:ColumnReference

The column reference.

Returns:boolean

true if in list references the same table as in cr.

Exceptions
StandardException:
Thrown on error
shallowCopyback to summary
protected InListOperatorNode shallowCopy() throws StandardException

Create a shallow copy of this InListOperatorNode whose operands are the same as this node's operands. Copy over all other necessary state, as well.

sortDescendingback to summary
protected boolean sortDescending()

Return whether or not the IN-list values for this node must be sorted in DESCENDING order.

toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.compile.BinaryListOperatorNode.toString.

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override