|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> sql >> [ compile overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.sql.compile
Class UserTypeConstantNode

java.lang.Objectorg.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ValueNode
org.apache.derby.impl.sql.compile.ConstantNode
org.apache.derby.impl.sql.compile.UserTypeConstantNode
- All Implemented Interfaces:
- org.apache.derby.iapi.sql.compile.Visitable
- public class UserTypeConstantNode
- extends ConstantNode
User type constants. These are created by built-in types that use user types as their implementation. This could also potentially be used by an optimizer that wanted to store plans for frequently-used parameter values. This is also used to represent nulls in user types, which occurs when NULL is inserted into or supplied as the update value for a usertype column.
| Field Summary | |
(package private) java.lang.Object |
value
|
| Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode |
clause, dataTypeServices, IN_HAVING_CLAUSE, IN_SELECT_LIST, IN_UNKNOWN_CLAUSE, IN_WHERE_CLAUSE, transformed |
| 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 | |
UserTypeConstantNode()
|
|
| Method Summary | |
ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.Vector aggregateVector)
Bind this expression. |
boolean |
constantExpression(PredicateList whereClause)
Return whether or not this expression tree represents a constant value. |
(package private) void |
generateConstant(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
Should never be called for UserTypeConstantNode because we have our own generateExpression(). |
void |
generateExpression(ExpressionClassBuilder acb,
org.apache.derby.iapi.services.compiler.MethodBuilder mb)
For a UserTypeConstantNode, we have to store away the object somewhere and have a way to get it back at runtime. |
ValueNode |
getClone()
Return a clone of this node. |
java.lang.Object |
getConstantValueAsObject()
Return an Object representing the bind time value of this expression tree. |
java.lang.Object |
getObjectValue()
Return the object value of this user defined type. |
protected int |
getOrderableVariantType()
Return the variant type for the underlying expression. |
org.apache.derby.iapi.types.DataValueDescriptor |
getStorableValue()
Return the value of this user defined type as a Storable |
org.apache.derby.iapi.types.DataValueDescriptor |
getValue()
Get the value in this ConstantNode |
void |
init(java.lang.Object arg1)
Initializer for a typed null node or a date, time, or timestamp value |
void |
init(java.lang.Object typeId,
java.lang.Object nullable,
java.lang.Object maximumWidth)
Initializer for non-numeric types |
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 |
isNull()
Return whether or not this node represents a typed null constant. |
void |
setObjectValue(java.lang.Object newValue)
Sets the object value of this user defined type |
(package private) void |
setValue(org.apache.derby.iapi.types.DataValueDescriptor value)
Set the value in this ConstantNode. |
java.lang.String |
toString()
Convert this object to a String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
value
java.lang.Object value
| Constructor Detail |
UserTypeConstantNode
public UserTypeConstantNode()
| Method Detail |
init
public void init(java.lang.Object arg1) throws org.apache.derby.iapi.error.StandardException
- Initializer for a typed null node
or a date, time, or timestamp value
- Overrides:
initin classQueryTreeNode
getObjectValue
public java.lang.Object getObjectValue()
- Return the object value of this user defined type.
isNull
public boolean isNull()
- Return whether or not this node represents a typed null constant.
- Overrides:
isNullin classConstantNode
getStorableValue
public org.apache.derby.iapi.types.DataValueDescriptor getStorableValue() throws org.apache.derby.iapi.error.StandardException
- Return the value of this user defined type as a Storable
setObjectValue
public void setObjectValue(java.lang.Object newValue)
- Sets the object value of this user defined type
getConstantValueAsObject
public java.lang.Object getConstantValueAsObject()
- Return an Object representing the bind time value of this
expression tree. If the expression tree does not evaluate to
a constant at bind time then we return null.
This is useful for bind time resolution of VTIs.
RESOLVE: What do we do for primitives?
- Overrides:
getConstantValueAsObjectin classValueNode
generateExpression
public void generateExpression(ExpressionClassBuilder acb, org.apache.derby.iapi.services.compiler.MethodBuilder mb) throws org.apache.derby.iapi.error.StandardException
- For a UserTypeConstantNode, we have to store away the object somewhere
and have a way to get it back at runtime.
These objects are serializable. This gives us at least two options:
1) serialize it out into a byte array field, and serialize
it back in when needed, from the field.
2) have an array of objects in the prepared statement and a #,
to find the object directly. Because it is serializable, it
will store with the rest of the executable just fine.
Choice 2 gives better performance -- the ser/deser cost is paid
on database access for the statement, not for each execution of it.
However, it requires some infrastructure support from prepared
statements. For now, we take choice 3, and make some assumptions
about available methods on the user type. This choice has the
shortcoming that it will not work for arbitrary user types.
REVISIT and implement choice 2 when a general solution is needed.
A null is generated as a Null value cast to the type of the constant node.
- Overrides:
generateExpressionin classConstantNode
generateConstant
void generateConstant(ExpressionClassBuilder acb, org.apache.derby.iapi.services.compiler.MethodBuilder mb) throws org.apache.derby.iapi.error.StandardException
- Should never be called for UserTypeConstantNode because
we have our own generateExpression().
- Specified by:
generateConstantin classConstantNode
init
public void init(java.lang.Object typeId, java.lang.Object nullable, java.lang.Object maximumWidth) throws org.apache.derby.iapi.error.StandardException
- Initializer for non-numeric types
- Overrides:
initin classQueryTreeNode
setValue
void setValue(org.apache.derby.iapi.types.DataValueDescriptor value)
- Set the value in this ConstantNode.
getValue
public org.apache.derby.iapi.types.DataValueDescriptor getValue()
- Get the value in this ConstantNode
toString
public java.lang.String toString()
- Convert this object to a String. See comments in QueryTreeNode.java
for how this should be done for tree printing.
isCloneable
public boolean isCloneable()
- Return whether or not this expression tree is cloneable.
- Overrides:
isCloneablein classValueNode
getClone
public ValueNode getClone()
bindExpression
public ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
- Bind this expression. This means binding the sub-expressions,
as well as figuring out what the return type is for this expression.
In this case, there are no sub-expressions, and the return type
is already known, so this is just a stub.
- Overrides:
bindExpressionin classValueNode
isConstantExpression
public boolean isConstantExpression()
- Return whether or not this expression tree represents a constant expression.
- Overrides:
isConstantExpressionin classValueNode
constantExpression
public boolean constantExpression(PredicateList whereClause)
- Description copied from class:
ValueNode - Return whether or not this expression tree represents a constant value.
In this case, "constant" means that it will always evaluate to the
same thing, even if it includes columns. A column is constant if it
is compared to a constant expression.
- Overrides:
constantExpressionin classValueNode
getOrderableVariantType
protected int 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
VARIANT - immutable
- Overrides:
getOrderableVariantTypein classValueNode
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> sql >> [ compile overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC