Class InListOperatorNode
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ValueNode
org.apache.derby.impl.sql.compile.BinaryListOperatorNode
org.apache.derby.impl.sql.compile.InListOperatorNode
- All Implemented Interfaces:
Visitable
An InListOperatorNode represents an IN list.
-
Field Summary
FieldsFields inherited from class org.apache.derby.impl.sql.compile.BinaryListOperatorNode
leftOperand, methodName, operator, rightOperandList
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
transformed
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
Constructor Summary
ConstructorsConstructorDescriptionInListOperatorNode
(ValueNode leftOperand, ValueNodeList rightOperandList, ContextManager cm) -
Method Summary
Modifier and TypeMethodDescription(package private) ValueNode
eliminateNots
(boolean underNotNode) Eliminate NotNodes in the current query block.(package private) void
Do code generation for this IN list operator.protected LocalField
Generate the code to create an array of DataValueDescriptors that will hold the IN-list values at execution time.(package private) void
generateStartStopKey
(boolean isAsc, boolean isStartKey, ExpressionClassBuilder acb, MethodBuilder mb) Generate start/stop key for this IN list operator.private DataTypeDescriptor
Get the dominant type of all the operands in this IN list.protected boolean
Return whether or not the IN-list values for this node are ordered.protected void
Indicate that the IN-list values for this node are ordered (i.e. they are all constants and they have been sorted).protected void
Indicate that the IN-list values for this node must be sorted in DESCENDING order.(package private) ValueNode
preprocess
(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) Preprocess an expression tree.double
selectivity
(Optimizable optTable) The selectivity for an "IN" predicate is generally very small.(package private) boolean
See if this IN list operator is referencing the same table.protected InListOperatorNode
Create a shallow copy of this InListOperatorNode whose operands are the same as this node's operands.protected boolean
Return whether or not the IN-list values for this node must be sorted in DESCENDING order.toString()
Convert this object to a String.Methods inherited from class org.apache.derby.impl.sql.compile.BinaryListOperatorNode
acceptChildren, bindComparisonOperator, bindExpression, categorize, constantExpression, getLeftOperand, getOrderableVariantType, getRightOperandList, isConstantExpression, isEquivalent, printSubNodes, remapColumnReferencesToExpressions, setLeftOperand, setRightOperandList
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isParameterNode, isRelationalOperator, isSameNodeKind, optimizableEqualityNode, putAndsOnTop, requiresTypeFromContext, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
Methods inherited from class org.apache.derby.impl.sql.compile.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, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
-
Field Details
-
isOrdered
private boolean isOrdered -
sortDescending
private boolean sortDescending
-
-
Constructor Details
-
InListOperatorNode
InListOperatorNode(ValueNode leftOperand, ValueNodeList rightOperandList, ContextManager cm) throws StandardException - Parameters:
leftOperand
- The left operand of the noderightOperandList
- The right operand list of the nodecm
- Context manager- Throws:
StandardException
-
-
Method Details
-
toString
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.- Overrides:
toString
in classBinaryListOperatorNode
- Returns:
- This object as a String
-
shallowCopy
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.- Throws:
StandardException
-
preprocess
ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException 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.- Overrides:
preprocess
in classBinaryListOperatorNode
- Parameters:
numTables
- Number of tables in the DML StatementouterFromList
- FromList from outer query blockouterSubqueryList
- SubqueryList from outer query blockouterPredicateList
- PredicateList from outer query block- Returns:
- The modified expression
- Throws:
StandardException
- Thrown on error
-
getDominantType
Get the dominant type of all the operands in this IN list.- Returns:
- the type descriptor for the dominant type
- See Also:
-
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.- Overrides:
eliminateNots
in classValueNode
- Parameters:
underNotNode
- Whether or not we are under a NotNode.- Returns:
- The modified expression
- Throws:
StandardException
- Thrown on error
-
selfReference
See if this IN list operator is referencing the same table.- Parameters:
cr
- The column reference.- Returns:
- true if in list references the same table as in cr.
- Throws:
StandardException
- Thrown on error
-
selectivity
The selectivity for an "IN" predicate is generally very small. This is an estimate applicable when in list are not all constants.- Overrides:
selectivity
in classValueNode
-
generateExpression
Do code generation for this IN list operator.- Overrides:
generateExpression
in classValueNode
- Parameters:
acb
- The ExpressionClassBuilder for the class we're generatingmb
- The MethodBuilder the expression will go into- Throws:
StandardException
- Thrown on error
-
generateListAsArray
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
- The ExpressionClassBuilder for the class we're generatingmb
- The MethodBuilder the expression will go into- Throws:
StandardException
-
generateStartStopKey
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
- is the index ascending on the column in questionisStartKey
- are we generating start key or notacb
- The ExpressionClassBuilder for the class we're generatingmb
- The MethodBuilder the expression will go into- Throws:
StandardException
- Thrown on error
-
markAsOrdered
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). -
markSortDescending
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. -
isOrdered
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. -
sortDescending
protected boolean sortDescending()Return whether or not the IN-list values for this node must be sorted in DESCENDING order.
-