Class ValueNodeList
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.QueryTreeNodeVector<ValueNode>
org.apache.derby.impl.sql.compile.ValueNodeList
A ValueNodeList represents a list of ValueNodes within a specific predicate
e.g. IN list, NOT IN list or BETWEEN in a DML statement.
-
Field Summary
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNodeVector
eltClass
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
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
addValueNode
(ValueNode valueNode) Add a ValueNode to the list.(package private) boolean
allSamePrecendence
(int precedence) Return whether or not all of the entries in the list have the same type precendence as the specified value.(package private) void
bindExpression
(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) Bind this expression.(package private) boolean
categorize
(JBitSet referencedTabs, boolean simplePredsOnly) Categorize this predicate.(package private) void
comparable
(ValueNode leftOperand) Determine whether or not the leftOperand is comparable() with all of the elements in the list.(package private) void
compatible
(ValueNode leftOperand) Make sure that passed ValueNode's type is compatible with the non-parameter elements in the ValueNodeList.(package private) boolean
constantExpression
(PredicateList whereClause) (package private) boolean
Does this list contain all ConstantNodes?(package private) boolean
Does this list contain all ParameterNodes?(package private) boolean
Does this list *only* contain constant and/or parameter nodes?(package private) boolean
Does this list contain a ParameterNode?(package private) void
eliminateNots
(boolean underNotNode) Eliminate NotNodes in all the nodes in this list.(package private) void
Generate a SQL->Java->SQL conversion tree any node in the list which is not a system built-in type.(package private) DataTypeDescriptor
Get the dominant DataTypeServices from the elements in the list.protected int
Return the variant type for the underlying expression.(package private) DataTypeDescriptor
Get the first non-null DataTypeServices from the elements in the list.(package private) boolean
Return whether or not this expression tree represents a constant expression.(package private) boolean
isEquivalent
(ValueNodeList other) Check if all the elements in this list are equivalent to the elements in another list.(package private) boolean
Determine whether or not any of the elements in the list are nullable.(package private) void
preprocess
(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) Preprocess a ValueNodeList.(package private) ValueNodeList
Remap all ColumnReferences in this tree to be clones of the underlying expression.(package private) void
setParameterDescriptor
(DataTypeDescriptor descriptor) Set the descriptor for every ParameterNode in the list.(package private) void
sortInAscendingOrder
(DataValueDescriptor judgeODV) Sort the entries in the list in ascending order.Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNodeVector
acceptChildren, addElement, destructiveAppend, elementAt, indexOf, insertElementAt, iterator, nondestructiveAppend, printSubNodes, removeAllElements, removeElement, removeElementAt, setElementAt, size
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, generate, 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, toString, treePrint, treePrint, verifyClassExist
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ValueNodeList
ValueNodeList(ContextManager cm)
-
-
Method Details
-
addValueNode
Add a ValueNode to the list.- Parameters:
valueNode
- A ValueNode to add to the list- Throws:
StandardException
- Thrown on error
-
bindExpression
void bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException Bind this expression. This means binding the sub-expressions, as well as figuring out what the return type is for this expression.- Parameters:
fromList
- The FROM list for the query this expression is in, for binding columns.subqueryList
- The subquery list being built as we find SubqueryNodesaggregates
- The aggregate list being built as we find AggregateNodes- Throws:
StandardException
- Thrown on error
-
genSQLJavaSQLTrees
Generate a SQL->Java->SQL conversion tree any node in the list which is not a system built-in type. This is useful when doing comparisons, built-in functions, etc. on java types which have a direct mapping to system built-in types.- Throws:
StandardException
- Thrown on error
-
getDominantTypeServices
Get the dominant DataTypeServices from the elements in the list. This method will also set the correct collation information on the dominant DataTypeService if we are dealing with character string datatypes. Algorithm for determining collation information This method will check if it is dealing with character string datatypes. If yes, then it will check if all the character string datatypes have the same collation derivation and collation type associated with them. If not, then the resultant DTD from this method will have collation derivation of NONE. If yes, then the resultant DTD from this method will have the same collation derivation and collation type as all the character string datatypes. Note that this method calls DTD.getDominantType and that method returns the dominant type of the 2 DTDs involved in this method. That method sets the collation info on the dominant type following the algorithm mentioned in the comments of- Returns:
- DataTypeServices The dominant DataTypeServices.
- Throws:
StandardException
- Thrown on error- See Also:
-
getTypeServices
Get the first non-null DataTypeServices from the elements in the list.- Returns:
- DataTypeServices The first non-null DataTypeServices.
- Throws:
StandardException
- Thrown on error
-
allSamePrecendence
boolean allSamePrecendence(int precedence) Return whether or not all of the entries in the list have the same type precendence as the specified value.- Parameters:
precedence
- The specified precedence.- Returns:
- Whether or not all of the entries in the list have the same type precendence as the specified value.
-
compatible
Make sure that passed ValueNode's type is compatible with the non-parameter elements in the ValueNodeList.- Parameters:
leftOperand
- Check for compatibility against this parameter's type- Throws:
StandardException
-
comparable
Determine whether or not the leftOperand is comparable() with all of the elements in the list. Throw an exception if any of them are not comparable.- Parameters:
leftOperand
- The left side of the expression- Throws:
StandardException
- Thrown on error
-
isNullable
Determine whether or not any of the elements in the list are nullable.- Returns:
- boolean Whether or not any of the elements in the list are nullable.
- Throws:
StandardException
-
containsParameterNode
boolean containsParameterNode()Does this list contain a ParameterNode?- Returns:
- boolean Whether or not the list contains a ParameterNode
-
containsAllParameterNodes
boolean containsAllParameterNodes()Does this list contain all ParameterNodes?- Returns:
- boolean Whether or not the list contains all ParameterNodes
-
containsAllConstantNodes
boolean containsAllConstantNodes()Does this list contain all ConstantNodes?- Returns:
- boolean Whether or not the list contains all ConstantNodes
-
containsOnlyConstantAndParamNodes
boolean containsOnlyConstantAndParamNodes()Does this list *only* contain constant and/or parameter nodes?- Returns:
- boolean True if every node in this list is either a constant node or parameter node.
-
sortInAscendingOrder
Sort the entries in the list in ascending order. (All values are assumed to be constants.)- Parameters:
judgeODV
- In case of type not exactly matching, the judging type.- Throws:
StandardException
- Thrown on error
-
eliminateNots
Eliminate NotNodes in all the nodes in this list.- Parameters:
underNotNode
- whether or not we are under a NotNode- Throws:
StandardException
- See Also:
-
setParameterDescriptor
Set the descriptor for every ParameterNode in the list.- Parameters:
descriptor
- The DataTypeServices to set for the parameters- Throws:
StandardException
- Thrown on error
-
preprocess
void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException Preprocess a ValueNodeList. For now, we just preprocess each ValueNode in the list.- Parameters:
numTables
- Number of tables in the DML StatementouterFromList
- FromList from outer query blockouterSubqueryList
- SubqueryList from outer query blockouterPredicateList
- PredicateList from outer query block- Throws:
StandardException
- Thrown on error
-
remapColumnReferencesToExpressions
Remap all ColumnReferences in this tree to be clones of the underlying expression.- Returns:
- ValueNodeList The remapped expression tree.
- Throws:
StandardException
- Thrown on error
-
isEquivalent
Check if all the elements in this list are equivalent to the elements in another list. The two lists must have the same size, and the equivalent nodes must appear in the same order in both lists, for the two lists to be equivalent.- Parameters:
other
- the other list- Returns:
true
if the two lists contain equivalent elements, orfalse
otherwise- Throws:
StandardException
- thrown on error- See Also:
-
isConstantExpression
boolean isConstantExpression()Return whether or not this expression tree represents a constant expression.- Returns:
- Whether or not this expression tree represents a constant expression.
-
constantExpression
- See Also:
-
categorize
Categorize this predicate. Initially, this means building a bit map of the referenced tables for each predicate. If the source of this ColumnReference (at the next underlying level) is not a ColumnReference or a VirtualColumnNode then this predicate will not be pushed down. For example, in: select * from (select 1 from s) a (x) where x = 1 we will not push down x = 1. NOTE: It would be easy to handle the case of a constant, but if the inner SELECT returns an arbitrary expression, then we would have to copy that tree into the pushed predicate, and that tree could contain subqueries and method calls. RESOLVE - revisit this issue once we have views.- Parameters:
referencedTabs
- JBitSet with bit map of referenced FromTablessimplePredsOnly
- Whether or not to consider method calls, field references and conditional nodes when building bit map- Returns:
- boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.
- Throws:
StandardException
- Thrown on error
-
getOrderableVariantType
Return the variant type for the underlying expression. The variant type can be: VARIANT - variant within a scan (method calls and non-static field access) SCAN_INVARIANT - invariant within a scan (column references from outer tables) QUERY_INVARIANT - invariant within the life of a query CONSTANT - constant- Returns:
- The variant type for the underlying expression.
- Throws:
StandardException
- thrown on error
-