public abstract class ValueNode extends QueryTreeNode
Modifier and Type | Field and Description |
---|---|
private DataTypeDescriptor |
dataTypeServices
The data type for this node.
|
(package private) boolean |
transformed |
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
Constructor and Description |
---|
ValueNode() |
ValueNode(java.lang.Object tcf,
java.lang.Object typeId,
java.lang.Object isNullable,
java.lang.Object maximumWidth)
Initializer for non-numeric types.
|
Modifier and Type | Method and Description |
---|---|
ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.List aggregateVector) |
ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.List aggregateVector,
boolean forQueryRewrite)
Bind this expression.
|
boolean |
categorize(JBitSet referencedTabs,
boolean simplePredsOnly)
Categorize this predicate.
|
ValueNode |
changeToCNF(boolean underTopAndNode)
Finish putting an expression into conjunctive normal
form.
|
ValueNode |
checkIsBoolean()
Bind time logic.
|
(package private) void |
checkTopPredicatesForEqualsConditions(int tableNumber,
boolean[] eqOuterCols,
int[] tableNumbers,
JBitSet[] tableColMap,
boolean resultColTable)
Update the array of columns in = conditions with expressions without
column references from the same table.
|
boolean |
constantExpression(PredicateList whereClause)
Return whether or not this expression tree represents a constant value.
|
void |
copyFields(ValueNode oldVN)
Copy all of the "appropriate fields" for a shallow copy.
|
(package private) ValueNode |
eliminateNots(boolean underNotNode)
Eliminate NotNodes in the current query block.
|
(package private) ValueNode |
evaluateConstantExpressions()
If this node is known to always evaluate to the same value, return a
node that represents that known value as a constant.
|
ValueNode |
genEqualsFalseTree()
Transform this into this = false.
|
protected void |
generate(ActivationClassBuilder acb,
MethodBuilder mb)
Do the code generation for this node.
|
void |
generateExpression(ExpressionClassBuilder acb,
MethodBuilder mb)
Generate code for this calculation.
|
void |
generateFilter(ExpressionClassBuilder ecb,
MethodBuilder mb)
The only reason this routine exists is so that I don't have to change
the protection on generateExpression() and rototill all of QueryTree.
|
(package private) ValueNode |
genIsNullTree(boolean notNull)
Transform this into this IS NULL or IS NOT NULL.
|
ValueNode |
genSQLJavaSQLTree()
Generate a SQL->Java->SQL conversion tree above the current node
and bind the new nodes individually.
|
ValueNode |
getClone()
Return a clone of this node.
|
java.lang.String |
getColumnName()
This is null so that the caller will substitute in the resultset generated
name as needed.
|
(package private) java.lang.Object |
getConstantValueAsObject()
Return an Object representing the bind time value of this
expression tree.
|
protected DataValueFactory |
getDataValueFactory()
Return the DataValueFactory
|
protected int |
getOrderableVariantType()
Return the variant type for the underlying expression.
|
java.lang.String |
getSchemaName()
This returns the user-supplied schema name of the column.
|
ResultColumn |
getSourceResultColumn()
Get the source for this ValueNode.
|
java.lang.String |
getTableName()
This returns the user-supplied table name of the column.
|
(package private) JBitSet |
getTablesReferenced()
Get a bit map of table references in this expression
|
(package private) boolean |
getTransformed()
Return whether or not this predicate has been transformed.
|
TypeCompiler |
getTypeCompiler()
Get the TypeCompiler from this ValueNode, based on its TypeId
using getTypeId().
|
TypeId |
getTypeId()
Get the TypeId from this ValueNode.
|
DataTypeDescriptor |
getTypeServices()
Get the DataTypeServices from this ValueNode.
|
void |
init(java.lang.Object typeId,
java.lang.Object precision,
java.lang.Object scale,
java.lang.Object isNullable,
java.lang.Object maximumWidth)
Initializer for numeric types.
|
boolean |
isBinaryEqualsOperatorNode()
Returns true if this value node is a equals operator.
|
(package private) boolean |
isBooleanFalse()
Does this represent a false constant.
|
(package private) boolean |
isBooleanTrue()
Does this represent a true constant.
|
boolean |
isCloneable()
Return whether or not this expression tree is cloneable.
|
boolean |
isConstantExpression()
Return whether or not this expression tree represents a constant expression.
|
protected abstract boolean |
isEquivalent(ValueNode other)
Tests if this node is equivalent to the specified ValueNode.
|
boolean |
isInListProbeNode()
Returns true if this value node is an operator created
for optimized performance of an IN list.
|
boolean |
isParameterNode()
Returns TRUE if this is a parameter node.
|
boolean |
isRelationalOperator()
Returns true if this ValueNode is a relational operator.
|
protected boolean |
isSameNodeType(ValueNode other)
Tests if this node is of the same type as the specified node as
reported by
QueryTreeNode.getNodeType() . |
boolean |
optimizableEqualityNode(Optimizable optTable,
int columnNumber,
boolean isNullOkay)
Return true if the predicate represents an optimizable equality node.
|
ValueNode |
preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
Preprocess an expression tree.
|
ValueNode |
putAndsOnTop()
Do the 1st step in putting an expression into conjunctive normal
form.
|
ValueNode |
remapColumnReferencesToExpressions()
Remap all ColumnReferences in this tree to be clones of the
underlying expression.
|
boolean |
requiresTypeFromContext()
Returns TRUE if the type of this node will be determined from the
context in which it is getting used.
|
double |
selectivity(Optimizable optTable)
The default selectivity for value nodes is 50%.
|
void |
setCollationInfo(DataTypeDescriptor collationInfoType)
Set the collation type and derivation of this node based upon
the collation information in the passed in type.
|
void |
setCollationInfo(int collationType,
int collationDerivation)
Set the collation type and derivation of this node based upon
the collation information passed in.
|
protected void |
setCollationUsingCompilationSchema()
Set the collation based upon the current schema with derivation
type implicit.
|
protected void |
setCollationUsingCompilationSchema(int collationDerivation)
There are many subclasses of ValueNode where we want the
DataTypeDescriptor of the node to have the same collation type as the
compilation schema's collation type.
|
void |
setNullability(boolean nullability)
Set the nullability of this value.
|
(package private) void |
setTransformed()
Mark this predicate has having been transformed (other predicates
were generated from it).
|
void |
setType(DataTypeDescriptor dataTypeServices)
Set the DataTypeServices for this ValueNode.
|
(package private) void |
setType(TypeId typeId,
boolean isNullable,
int maximumWidth)
Set this node's type from type components.
|
(package private) void |
setType(TypeId typeId,
int precision,
int scale,
boolean isNullable,
int maximumWidth)
Set this node's type from type components.
|
private void |
setValueCols(JBitSet[] tableColMap,
boolean[] eqOuterCols,
int colReference,
int resultTable)
Set eqOuterCols and the column in all the tables for constants,
parmeters and correlation columns
The column in the tableColMap is set only for the current table
if the table is the result column table.
|
java.lang.String |
toString()
Convert this object to a String.
|
boolean |
updatableByCursor() |
private void |
updateMaps(JBitSet[] tableColMap,
boolean[] eqOuterCols,
int[] tableNumbers,
int tableNumber,
int resultTable,
ValueNode arg1,
ValueNode arg2)
Set the correct bits in tableColMap and set the boolean value in eqOuterCols
given two arguments to an = predicate
tableColMap[t] - bit is set if the column is in an = predicate with a column
in table t, or a bit is set if the column is in an
= predicate with a constant,parameter or correlation variable
(for all table t, if this tableColMap is not for the
table with the result columns)
eqOuterCols[c] - is true if the column is in an = predicate with a constant,
parameter or correlation variable
|
boolean |
verifyChangeToCNF()
Verify that changeToCNF() did its job correctly.
|
(package private) boolean |
verifyEliminateNots()
Verify that eliminateNots() did its job correctly.
|
boolean |
verifyPutAndsOnTop()
Verify that putAndsOnTop() did its job correctly.
|
accept, acceptChildren, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, foundString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, orReliability, parseStatement, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, stackPrint, treePrint, treePrint, verifyClassExist
private DataTypeDescriptor dataTypeServices
boolean transformed
public ValueNode()
ValueNode(java.lang.Object tcf, java.lang.Object typeId, java.lang.Object isNullable, java.lang.Object maximumWidth) throws StandardException
tcf
- The factory to get the
DataTypeServicesFactory fromtypeId
- The TypeID of this new nodeisNullable
- The nullability of this new nodemaximumWidth
- The maximum width of this new nodeStandardException
final void setType(TypeId typeId, boolean isNullable, int maximumWidth) throws StandardException
StandardException
final void setType(TypeId typeId, int precision, int scale, boolean isNullable, int maximumWidth) throws StandardException
StandardException
public void init(java.lang.Object typeId, java.lang.Object precision, java.lang.Object scale, java.lang.Object isNullable, java.lang.Object maximumWidth) throws StandardException
init
in interface Node
init
in class QueryTreeNode
typeId
- The TypeID of this new nodeprecision
- The precision of this new nodescale
- The scale of this new nodeisNullable
- The nullability of this new nodemaximumWidth
- The maximum width of this new nodeStandardException
public java.lang.String toString()
toString
in class QueryTreeNode
public DataTypeDescriptor getTypeServices()
public void setNullability(boolean nullability) throws StandardException
StandardException
public void setCollationInfo(DataTypeDescriptor collationInfoType) throws StandardException
collationInfoType
- Type to take collation type and derivation from.StandardException
- Error setting type.public void setCollationInfo(int collationType, int collationDerivation) throws StandardException
collationType
- Collation typecollationDerivation
- Collation derivationStandardException
- Error setting typepublic TypeId getTypeId() throws StandardException
StandardException
protected final DataValueFactory getDataValueFactory()
public final TypeCompiler getTypeCompiler() throws StandardException
StandardException
public void setType(DataTypeDescriptor dataTypeServices) throws StandardException
dataTypeServices
- The DataTypeServices to set in this
ValueNodeStandardException
protected final void setCollationUsingCompilationSchema() throws StandardException
StandardException
protected final void setCollationUsingCompilationSchema(int collationDerivation) throws StandardException
collationDerivation
- This can be
StringDataValue#COLLATION_DERIVATION_IMPLICIT
StringDataValue#COLLATION_DERIVATION_NONE
StringDataValue#COLLATION_DERIVATION_EXPLICITStandardException
public ResultColumn getSourceResultColumn()
void setTransformed()
boolean getTransformed()
public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List aggregateVector) throws StandardException
StandardException
public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List aggregateVector, boolean forQueryRewrite) throws StandardException
fromList
- The FROM list to use for bindingsubqueryList
- The SubqueryList we are building as we hit
SubqueryNodes.aggregateVector
- The aggregate vector being built as we find AggregateNodesStandardException
- Thrown on errorpublic ValueNode genSQLJavaSQLTree() throws StandardException
StandardException
- Thrown on errorpublic ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException
numTables
- Number of tables in the DML StatementouterFromList
- FromList from outer query blockouterSubqueryList
- SubqueryList from outer query blockouterPredicateList
- PredicateList from outer query blockStandardException
- Thrown on errorValueNode evaluateConstantExpressions() throws StandardException
this
if the value is not knownStandardException
- if an error occurs during evaluationConstantExpressionVisitor
ValueNode eliminateNots(boolean underNotNode) throws StandardException
underNotNode
- Whether or not we are under a NotNode.StandardException
- Thrown on errorpublic ValueNode genEqualsFalseTree() throws StandardException
StandardException
- Thrown on errorValueNode genIsNullTree(boolean notNull) throws StandardException
notNull
- if true, transform this into IS NOT NULL;
otherwise, transform this into IS NULLStandardException
- Thrown on errorboolean verifyEliminateNots()
public ValueNode putAndsOnTop() throws StandardException
StandardException
- Thrown on errorpublic boolean verifyPutAndsOnTop()
public ValueNode changeToCNF(boolean underTopAndNode) throws StandardException
underTopAndNode
- Whether or not we are under a top level AndNode.StandardException
- Thrown on errorpublic boolean verifyChangeToCNF()
public boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) throws StandardException
referencedTabs
- JBitSet with bit map of referenced FromTablessimplePredsOnly
- Whether or not to consider method
calls, field references and conditional nodes
when building bit mapStandardException
- Thrown on errorpublic java.lang.String getSchemaName() throws StandardException
StandardException
public java.lang.String getTableName()
public boolean updatableByCursor()
public java.lang.String getColumnName()
JBitSet getTablesReferenced() throws StandardException
StandardException
- Thrown on errorpublic boolean isCloneable()
public ValueNode getClone() throws StandardException
StandardException
- Thrown on errorpublic void copyFields(ValueNode oldVN) throws StandardException
oldVN
- The ValueNode to copy from.StandardException
public ValueNode remapColumnReferencesToExpressions() throws StandardException
StandardException
- Thrown on errorpublic boolean isConstantExpression()
public boolean constantExpression(PredicateList whereClause)
protected int getOrderableVariantType() throws StandardException
StandardException
- Thrown on errorpublic ValueNode checkIsBoolean() throws StandardException
StandardException
- Thrown on errorjava.lang.Object getConstantValueAsObject() throws StandardException
StandardException
- Thrown on errorprotected final void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException
generate
in class QueryTreeNode
acb
- The ActivationClassBuilder for the class being builtmb
- The method the expression will go intoStandardException
- Thrown on errorpublic void generateFilter(ExpressionClassBuilder ecb, MethodBuilder mb) throws StandardException
ecb
- The ExpressionClassBuilder for the class being builtmb
- The method the expression will go intoStandardException
- Thrown on errorpublic double selectivity(Optimizable optTable) throws StandardException
StandardException
void checkTopPredicatesForEqualsConditions(int tableNumber, boolean[] eqOuterCols, int[] tableNumbers, JBitSet[] tableColMap, boolean resultColTable) throws StandardException
tableNumber
- The tableNumber of the table from which
the columns of interest come from.eqOuterCols
- Array of booleans for noting which columns
are in = predicates without columns from the
subquery block. May be null.tableNumbers
- Array of table numbers in this query block.tableColMap
- Array of bits for noting which columns
are in = predicates for each table in the
query block. May be null.resultColTable
- True if tableNumber is the table containing result
columnsStandardException
- Thrown on errorboolean isBooleanTrue()
boolean isBooleanFalse()
public void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
acb
- The ExpressionClassBuilder for the class being builtmb
- The method the expression will go intoStandardException
- Thrown on errorprivate void updateMaps(JBitSet[] tableColMap, boolean[] eqOuterCols, int[] tableNumbers, int tableNumber, int resultTable, ValueNode arg1, ValueNode arg2) throws StandardException
tableColMap
- Array of bitmaps for noting which columns are in =
predicates with columns from each tableeqOuterCols
- Array of booleans for noting which columns
are in = predicates without columns from the
subquery block.tableNumber
- table number for which we are setting up the MapsresultTable
- -1 if this table is not the result table; otherwise
the index into tableNumbers for the result tablearg1
- one side of the = predicatearg2
- other side of the = predicateStandardException
- Thrown on errorprivate void setValueCols(JBitSet[] tableColMap, boolean[] eqOuterCols, int colReference, int resultTable)
tableColMap
- Array of bitmaps for noting which columns are in =
predicates with columns from each tableeqOuterCols
- Array of booleans for noting which columns
are in = predicates without columns from the
subquery block.colReference
- The column to setresultTable
- If -1 set all the bit for all the tables for that
column; otherwise set the bit for the specified tablepublic boolean isRelationalOperator()
public boolean isBinaryEqualsOperatorNode()
isRelationalOperator()
public boolean isInListProbeNode()
public boolean optimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay) throws StandardException
optTable
- the table being optimized. Column reference must be from
this table.columnNumber
- the column number. One of the operands of this
predicate must be the column number specified by optTable/columnNumberisNullOkay
- if set to true we also consider IS NULL predicates;
otherwise consider only = predicates.StandardException
public boolean requiresTypeFromContext()
public boolean isParameterNode()
protected abstract boolean isEquivalent(ValueNode other) throws StandardException
This method provides basic expression matching facility for the derived class of ValueNode and it is used by the language layer to compare the node structural form of the two expressions for equivalence at bind phase.
Note that it is not comparing the actual row values at runtime to produce a result; hence, when comparing SQL NULLs, they are considered to be equivalent and not unknown.
One usage case of this method in this context is to compare the select column expression against the group by expression to check if they are equivalent. e.g.:
SELECT c1+c2 FROM t1 GROUP BY c1+c2
In general, node equivalence is determined by the derived class of ValueNode. But they generally abide to the rules below:
other
- the node to compare this ValueNode against.true
if the two nodes are equivalent,
false
otherwise.StandardException
protected final boolean isSameNodeType(ValueNode other)
QueryTreeNode.getNodeType()
.other
- the node to compare this value node against.true
if the two nodes are of the same type.Apache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.