Class UnaryArithmeticOperatorNode
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.QueryTreeNode
-
- org.apache.derby.impl.sql.compile.ValueNode
-
- org.apache.derby.impl.sql.compile.OperatorNode
-
- org.apache.derby.impl.sql.compile.UnaryOperatorNode
-
- org.apache.derby.impl.sql.compile.UnaryArithmeticOperatorNode
-
- All Implemented Interfaces:
Visitable
class UnaryArithmeticOperatorNode extends UnaryOperatorNode
This node represents a unary arithmetic operator
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
K_ABS
(package private) static int
K_MINUS
(package private) static int
K_PLUS
(package private) static int
K_SQRT
(package private) int
kind
This class is used to hold logically different objects for space efficiency.private static java.lang.String[]
UNARY_METHODS
private static java.lang.String[]
UNARY_OPERATORS
-
Fields inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
K_BASE, K_XMLPARSE, K_XMLSERIALIZE, methodName, operand, operator, receiverInterfaceType, resultInterfaceType, UnaryArgTypes, UnaryMethodNames, UnaryOperators, UnaryResultTypes
-
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
transformed
-
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 Constructor Description UnaryArithmeticOperatorNode(ValueNode operand, int kind, ContextManager cm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) ValueNode
bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates)
Bind this operator(package private) void
bindParameter()
For SQRT and ABS the parameter becomes a DOUBLE.private void
bindSQRTABS()
Bind SQRT or ABSprivate void
checkOperandIsNumeric(TypeId operandType)
Only called for Unary +/-.(package private) void
generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
Do code generation for this unary plus operatorboolean
isParameterNode()
A +?(package private) boolean
isSameNodeKind(ValueNode o)
Some node classes represent several logical node types (to reduce footprint), which we call kinds.boolean
requiresTypeFromContext()
Unary + and - require their type to be set if they wrap another node (e.g. a parameter) that requires type from its context.(package private) void
setType(DataTypeDescriptor descriptor)
We are overwriting this method here because for -?-
Methods inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
acceptChildren, addXmlOpMethodParams, bindOperand, categorize, constantExpression, getOperand, getOperatorString, getOrderableVariantType, getParameterOperand, getReceiverInterfaceName, isConstantExpression, isEquivalent, preprocess, printSubNodes, remapColumnReferencesToExpressions, setMethodName, setOperator, toString
-
Methods inherited from class org.apache.derby.impl.sql.compile.OperatorNode
pushSqlXmlUtil
-
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isRelationalOperator, optimizableEqualityNode, putAndsOnTop, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
-
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, 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, treePrint, treePrint, verifyClassExist
-
-
-
-
Field Detail
-
UNARY_OPERATORS
private static final java.lang.String[] UNARY_OPERATORS
-
UNARY_METHODS
private static final java.lang.String[] UNARY_METHODS
-
K_PLUS
static final int K_PLUS
- See Also:
- Constant Field Values
-
K_MINUS
static final int K_MINUS
- See Also:
- Constant Field Values
-
K_SQRT
static final int K_SQRT
- See Also:
- Constant Field Values
-
K_ABS
static final int K_ABS
- See Also:
- Constant Field Values
-
kind
final int kind
This class is used to hold logically different objects for space efficiency.kind
represents the logical object type. See alsoValueNode.isSameNodeKind(org.apache.derby.impl.sql.compile.ValueNode)
.
-
-
Constructor Detail
-
UnaryArithmeticOperatorNode
UnaryArithmeticOperatorNode(ValueNode operand, int kind, ContextManager cm) throws StandardException
- Parameters:
operand
- The operand of the nodekind
- unary operator identitycm
- context manager- Throws:
StandardException
-
-
Method Detail
-
requiresTypeFromContext
public boolean requiresTypeFromContext()
Unary + and - require their type to be set if they wrap another node (e.g. a parameter) that requires type from its context.- Overrides:
requiresTypeFromContext
in classValueNode
- Returns:
- Whether this node's type will be determined from the context
- See Also:
ValueNode.requiresTypeFromContext()
-
isParameterNode
public boolean isParameterNode()
A +? or a -? is considered a parameter.- Overrides:
isParameterNode
in classValueNode
-
bindParameter
void bindParameter() throws StandardException
For SQRT and ABS the parameter becomes a DOUBLE. For unary + and - no change is made to the underlying node. Once this node's type is set using setType, then the underlying node will have its type set.- Overrides:
bindParameter
in classUnaryOperatorNode
- Throws:
StandardException
- Thrown if ? parameter doesn't have a type bound to it yet. ? parameter where it isn't allowed.
-
bindExpression
ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates) throws StandardException
Bind this operator- Overrides:
bindExpression
in classUnaryOperatorNode
- Parameters:
fromList
- The query's FROM listsubqueryList
- The subquery list being built as we find SubqueryNodesaggregates
- The aggregate list being built as we find AggregateNodes- Returns:
- The new top of the expression tree.
- Throws:
StandardException
- Thrown on error
-
checkOperandIsNumeric
private void checkOperandIsNumeric(TypeId operandType) throws StandardException
Only called for Unary +/-.- Throws:
StandardException
-
generateExpression
void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
Do code generation for this unary plus operator- Overrides:
generateExpression
in classUnaryOperatorNode
- Parameters:
acb
- The ExpressionClassBuilder for the class we're generatingmb
- The method the expression will go into- Throws:
StandardException
- Thrown on error
-
bindSQRTABS
private void bindSQRTABS() throws StandardException
Bind SQRT or ABS- Throws:
StandardException
- Thrown on error
-
setType
void setType(DataTypeDescriptor descriptor) throws StandardException
We are overwriting this method here because for -?/+?, we now know the type of these dynamic parameters and hence we can do the parameter binding. The setType method will call the binding code after setting the type of the parameter- Overrides:
setType
in classValueNode
- Parameters:
descriptor
- The DataTypeServices to set in this ValueNode- Throws:
StandardException
-
isSameNodeKind
boolean isSameNodeKind(ValueNode o)
Description copied from class:ValueNode
Some node classes represent several logical node types (to reduce footprint), which we call kinds. This means that implementations ofValueNode.isEquivalent(org.apache.derby.impl.sql.compile.ValueNode)
cannot always just useinstanceof
to check if the other node represents the same kind. Hence this method needs to be overridden by all node classes that represent several kinds. This default implementation does not look at kinds. It is only called from implementations ofisEquivalent
.- Overrides:
isSameNodeKind
in classUnaryOperatorNode
- Parameters:
o
- The other value node whose kind we want to compare with.- Returns:
true
ifthis
ando
represent the same logical node type, i.e. kind.
-
-