org.apache.derby.impl.sql.compile
Class UnaryComparisonOperatorNode

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.ValueNode
          extended byorg.apache.derby.impl.sql.compile.UnaryOperatorNode
              extended byorg.apache.derby.impl.sql.compile.UnaryComparisonOperatorNode
All Implemented Interfaces:
Visitable
Direct Known Subclasses:
IsNullNode

public class UnaryComparisonOperatorNode
extends UnaryOperatorNode

This node is the superclass for all unary comparison operators, such as is null and is not null.

Author:
Jerry Brenner

Field Summary
 
Fields inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
IS_NULL, methodName, NOT, operand, operator, UNARY_MINUS, UNARY_PLUS
 
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
UnaryComparisonOperatorNode()
           
 
Method Summary
 void bindComparisonOperator()
          Set the type info for this node.
 ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          Bind this comparison operator.
(package private)  ValueNode eliminateNots(boolean underNotNode)
          Eliminate NotNodes in the current query block.
 void generateAbsoluteColumnId(MethodBuilder mb, Optimizable optTable)
           
 void generateExpressionOperand(Optimizable optTable, int columnPosition, ExpressionClassBuilder acb, MethodBuilder mb)
           
 void generateOrderedNulls(MethodBuilder mb)
           
 void generateQualMethod(ExpressionClassBuilder acb, MethodBuilder mb, Optimizable optTable)
           
 void generateRelativeColumnId(MethodBuilder mb, Optimizable optTable)
           
private  int getAbsoluteColumnPosition(Optimizable optTable)
          Get the absolute 0-based column position of the ColumnReference from the conglomerate for this Optimizable.
 ColumnReference getColumnOperand(int tableNumber, int columnPosition)
           
 ColumnReference getColumnOperand(Optimizable optTable)
           
 ColumnReference getColumnOperand(Optimizable optTable, int columnPosition)
           
 ValueNode getExpressionOperand(int tableNumber, int columnNumber)
           
(package private)  UnaryOperatorNode getNegation(ValueNode operand)
          Negate the comparison.
 int getOrderableVariantType(Optimizable optTable)
           
 int getStartOperator(Optimizable optTable)
           
 int getStopOperator(Optimizable optTable)
           
 boolean isQualifier(Optimizable optTable)
           
 boolean orderedNulls()
           
 boolean selfComparison(ColumnReference cr)
           
 
Methods inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
accept, bindParameter, bindUnaryOperator, categorize, constantExpression, generateExpression, getOperand, getOperatorString, getOrderableVariantType, getReceiverInterfaceName, init, init, isConstantExpression, preprocess, printSubNodes, remapColumnReferencesToExpressions, setClause, setMethodName, setOperator, toString
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkReliability, checkReliability, checkTopPredicatesForEqualsConditions, copyFields, genEqualsFalseTree, generate, generateFilter, genIsNullTree, genSQLJavaSQLTree, getClause, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, init, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isParameterNode, isRelationalOperator, optimizableEqualityNode, putAndsOnTop, selectivity, setDescriptor, setTransformed, setType, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, referencesSessionSchema, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnaryComparisonOperatorNode

public UnaryComparisonOperatorNode()
Method Detail

bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         throws StandardException
Bind this comparison operator. All that has to be done for binding a comparison operator is to bind the operand and set the result type to SQLBoolean.

Overrides:
bindExpression in class UnaryOperatorNode
Parameters:
fromList - The query's FROM list
subqueryList - The subquery list being built as we find SubqueryNodes
aggregateVector - The aggregate vector being built as we find AggregateNodes
Returns:
The new top of the expression tree.
Throws:
StandardException - Thrown on error

bindComparisonOperator

public void bindComparisonOperator()
                            throws StandardException
Set the type info for this node. This method is useful both during binding and when we generate nodes within the language module outside of the parser.

Returns:
Nothing
Throws:
StandardException - Thrown on error

eliminateNots

ValueNode eliminateNots(boolean underNotNode)
                  throws StandardException
Eliminate NotNodes in the current query block. We traverse the tree, inverting ANDs and ORs and eliminating NOTs as we go. We stop at ComparisonOperators and boolean expressions. We invert ComparisonOperators and replace boolean expressions with boolean expression = false. NOTE: Since we do not recurse under ComparisonOperators, there still could be NotNodes left in the tree.

Overrides:
eliminateNots in class ValueNode
Parameters:
underNotNode - Whether or not we are under a NotNode.
Returns:
The modified expression
Throws:
StandardException - Thrown on error

getNegation

UnaryOperatorNode getNegation(ValueNode operand)
                        throws StandardException
Negate the comparison.

Parameters:
operand - The operand of the comparison operator
Returns:
BinaryOperatorNode The negated expression
Throws:
StandardException - Thrown on error

getColumnOperand

public ColumnReference getColumnOperand(Optimizable optTable,
                                        int columnPosition)
See Also:
RelationalOperator.getColumnOperand(org.apache.derby.iapi.sql.compile.Optimizable, int)

getColumnOperand

public ColumnReference getColumnOperand(int tableNumber,
                                        int columnPosition)
See Also:
RelationalOperator.getColumnOperand(org.apache.derby.iapi.sql.compile.Optimizable, int)

getColumnOperand

public ColumnReference getColumnOperand(Optimizable optTable)
See Also:
RelationalOperator.getColumnOperand(org.apache.derby.iapi.sql.compile.Optimizable, int)

selfComparison

public boolean selfComparison(ColumnReference cr)
See Also:
RelationalOperator.selfComparison(org.apache.derby.impl.sql.compile.ColumnReference)

getExpressionOperand

public ValueNode getExpressionOperand(int tableNumber,
                                      int columnNumber)
See Also:
RelationalOperator.getExpressionOperand(int, int)

generateExpressionOperand

public void generateExpressionOperand(Optimizable optTable,
                                      int columnPosition,
                                      ExpressionClassBuilder acb,
                                      MethodBuilder mb)
                               throws StandardException
Throws:
StandardException - Thrown on error
See Also:
RelationalOperator.generateExpressionOperand(org.apache.derby.iapi.sql.compile.Optimizable, int, org.apache.derby.impl.sql.compile.ExpressionClassBuilder, org.apache.derby.iapi.services.compiler.MethodBuilder)

getStartOperator

public int getStartOperator(Optimizable optTable)
See Also:
RelationalOperator.getStartOperator(org.apache.derby.iapi.sql.compile.Optimizable)

getStopOperator

public int getStopOperator(Optimizable optTable)
See Also:
RelationalOperator.getStopOperator(org.apache.derby.iapi.sql.compile.Optimizable)

generateOrderedNulls

public void generateOrderedNulls(MethodBuilder mb)
See Also:
RelationalOperator.generateOrderedNulls(org.apache.derby.iapi.services.compiler.MethodBuilder)

generateQualMethod

public void generateQualMethod(ExpressionClassBuilder acb,
                               MethodBuilder mb,
                               Optimizable optTable)
                        throws StandardException
Throws:
StandardException - Thrown on error
See Also:
RelationalOperator.generateQualMethod(org.apache.derby.impl.sql.compile.ExpressionClassBuilder, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)

generateAbsoluteColumnId

public void generateAbsoluteColumnId(MethodBuilder mb,
                                     Optimizable optTable)
See Also:
RelationalOperator.generateAbsoluteColumnId(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)

generateRelativeColumnId

public void generateRelativeColumnId(MethodBuilder mb,
                                     Optimizable optTable)
See Also:
RelationalOperator.generateRelativeColumnId(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)

getAbsoluteColumnPosition

private int getAbsoluteColumnPosition(Optimizable optTable)
Get the absolute 0-based column position of the ColumnReference from the conglomerate for this Optimizable.

Parameters:
optTable - The Optimizable
Returns:
The absolute 0-based column position of the ColumnReference

orderedNulls

public boolean orderedNulls()
See Also:
RelationalOperator.orderedNulls()

isQualifier

public boolean isQualifier(Optimizable optTable)
See Also:
RelationalOperator.isQualifier(org.apache.derby.iapi.sql.compile.Optimizable)

getOrderableVariantType

public int getOrderableVariantType(Optimizable optTable)
                            throws StandardException
Throws:
StandardException - thrown on error
See Also:
RelationalOperator.getOrderableVariantType(org.apache.derby.iapi.sql.compile.Optimizable)


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.