|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ValueNode
public abstract class ValueNode
A ValueNode is an abstract class for all nodes that can represent data values, that is, constants, columns, and expressions.
Field Summary | |
---|---|
private DataTypeDescriptor |
dataTypeServices
The data type for this node. |
(package private) boolean |
transformed
|
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
---|
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired |
Constructor Summary | |
---|---|
ValueNode()
|
|
ValueNode(java.lang.Object tcf,
java.lang.Object typeId,
java.lang.Object isNullable,
java.lang.Object maximumWidth)
Initializer for non-numeric types. |
Method Summary | |
---|---|
ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.Vector aggregateVector)
|
ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.Vector 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. |
ValueNode |
genIsNullTree()
Transform this into this is 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private DataTypeDescriptor dataTypeServices
boolean transformed
Constructor Detail |
---|
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 node
StandardException
Method Detail |
---|
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 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 node
StandardException
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 derivation
StandardException
- 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
ValueNode
StandardException
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_EXPLICIT
StandardException
public ResultColumn getSourceResultColumn()
void setTransformed()
boolean getTransformed()
public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector) throws StandardException
StandardException
public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector 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 AggregateNodes
StandardException
- 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 block
StandardException
- Thrown on errorValueNode evaluateConstantExpressions() throws StandardException
this
if the value is not known
StandardException
- 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 errorpublic ValueNode genIsNullTree() throws StandardException
StandardException
- 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 map
StandardException
- 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 into
StandardException
- 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 into
StandardException
- 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
columns
StandardException
- 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 into
StandardException
- 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 = predicate
StandardException
- 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()
RelationalOperator
,
BinaryRelationalOperatorNode
,
IsNullNode
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.
|
Built on Thu 2012-03-29 21:53:33+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |