|
||||||||||
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
A ValueNode is an abstract class for all nodes that can represent data values, that is, constants, columns, and expressions.
Field Summary | |
protected int |
clause
|
protected DataTypeDescriptor |
dataTypeServices
|
static int |
IN_HAVING_CLAUSE
|
static int |
IN_SELECT_LIST
|
static int |
IN_UNKNOWN_CLAUSE
|
static int |
IN_WHERE_CLAUSE
|
(package private) boolean |
transformed
|
private TypeCompiler |
typeCompiler
|
private TypeId |
typeId
|
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset |
Constructor Summary | |
|
ValueNode()
|
(package private) |
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. |
void |
checkReliability(int fragmentBitMask,
java.lang.String fragmentType)
Bind time logic. |
void |
checkReliability(java.lang.String fragmentType,
int fragmentBitMask)
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. |
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. |
int |
getClause()
Get the clause that this node appears in. |
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()
When the value node is in a result column of a select list, the user can request metadata information. |
ResultColumn |
getSourceResultColumn()
Get the source for this ValueNode. |
java.lang.String |
getTableName()
|
(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. |
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. |
boolean |
isParameterNode()
Returns TRUE if this is a parameter node. |
boolean |
isRelationalOperator()
Returns true if this ValueNode is a relational operator. |
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. |
double |
selectivity(Optimizable optTable)
The default selectivity for value nodes is 50%. |
void |
setClause(int clause)
Set the clause that this node appears in. |
void |
setDescriptor(DataTypeDescriptor descriptor)
Set the DataTypeServices for this ValueNode. |
(package private) void |
setTransformed()
Mark this predicate has having been transformed (other predicates were generated from it). |
void |
setType(DataTypeDescriptor dataTypeServices)
Set the DataTypeServices in this ValueNode. |
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. |
private void |
throwReliabilityException(java.lang.String fragmentType)
Common code for the 2 checkReliability functions. |
java.lang.String |
toString()
Convert this object to a String. |
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 |
public static final int IN_UNKNOWN_CLAUSE
public static final int IN_SELECT_LIST
public static final int IN_WHERE_CLAUSE
public static final int IN_HAVING_CLAUSE
protected DataTypeDescriptor dataTypeServices
private TypeId typeId
private TypeCompiler typeCompiler
protected int clause
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 |
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 TypeId getTypeId()
protected final DataValueFactory getDataValueFactory()
public TypeCompiler getTypeCompiler()
public void setType(DataTypeDescriptor dataTypeServices)
dataTypeServices
- The DataTypeServices to set in this
ValueNode
public void setDescriptor(DataTypeDescriptor descriptor)
descriptor
- The DataTypeServices to set for this ValueNode
public ResultColumn getSourceResultColumn()
public int getClause()
public void setClause(int clause)
clause
- The clause that this node appears in.
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 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()
public java.lang.String getTableName()
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)
oldVN
- The ValueNode to copy from.public ValueNode remapColumnReferencesToExpressions() throws StandardException
StandardException
- Thrown on errorpublic boolean isConstantExpression()
public boolean constantExpression(PredicateList whereClause)
public void checkReliability(java.lang.String fragmentType, int fragmentBitMask) throws StandardException
fragmentType
- Type of fragment as a String, for inclusion in error messages.fragmentBitMask
- Type of fragment as a bitmask of possible fragment types
StandardException
- Thrown on errorpublic void checkReliability(int fragmentBitMask, java.lang.String fragmentType) throws StandardException
fragmentBitMask
- Type of fragment as a bitmask of possible fragment typesfragmentType
- Type of fragment as a String, to be fetch for the error message.
StandardException
- Thrown on errorprivate void throwReliabilityException(java.lang.String fragmentType) throws StandardException
fragmentType
- Type of fragment as a string, for inclusion in error messages.
StandardException
- Throws an error, always.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)
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
mb
- 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 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 isParameterNode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |