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
This node represents a unary arithmetic operator
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
(package private) final int
This class is used to hold logically different objects for space efficiency.private static final String[]
private static final String[]
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 -
Method Summary
Modifier and TypeMethodDescription(package private) ValueNode
bindExpression
(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) Bind this operator(package private) void
For SQRT and ABS the parameter becomes a DOUBLE.private void
Bind SQRT or ABSprivate void
checkOperandIsNumeric
(TypeId operandType) Only called for Unary +/-.(package private) void
Do code generation for this unary plus operatorboolean
A +?(package private) boolean
Some node classes represent several logical node types (to reduce footprint), which we call kinds.boolean
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 Details
-
UNARY_OPERATORS
-
UNARY_METHODS
-
K_PLUS
static final int K_PLUS- See Also:
-
K_MINUS
static final int K_MINUS- See Also:
-
K_SQRT
static final int K_SQRT- See Also:
-
K_ABS
static final int K_ABS- See Also:
-
kind
final int kindThis 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 Details
-
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 Details
-
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:
-
isParameterNode
public boolean isParameterNode()A +? or a -? is considered a parameter.- Overrides:
isParameterNode
in classValueNode
-
bindParameter
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, 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
Only called for Unary +/-.- Throws:
StandardException
-
generateExpression
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
Bind SQRT or ABS- Throws:
StandardException
- Thrown on error
-
setType
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
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.
-