Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.sql.compile
Class BinaryComparisonOperatorNode  view BinaryComparisonOperatorNode download BinaryComparisonOperatorNode.java

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.BinaryOperatorNode
              extended byorg.apache.derby.impl.sql.compile.BinaryComparisonOperatorNode
All Implemented Interfaces:
org.apache.derby.iapi.sql.compile.Visitable
Direct Known Subclasses:
BinaryRelationalOperatorNode

public abstract class BinaryComparisonOperatorNode
extends BinaryOperatorNode

This node is the superclass for all binary comparison operators, such as =, <>, <, etc.


Field Summary
private  boolean betweenSelectivity
           
private  boolean forQueryRewrite
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.BinaryOperatorNode
AND, BinaryArgTypes, BinaryMethodNames, BinaryOperators, BinaryResultTypes, CONCATENATE, DIVIDE, EQ, GE, GT, LE, leftInterfaceType, leftOperand, LIKE, LT, methodName, MINUS, NE, operator, operatorType, OR, PLUS, receiver, resultInterfaceType, rightInterfaceType, rightOperand, TIMES, XMLEXISTS_OP
 
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
BinaryComparisonOperatorNode()
           
 
Method Summary
 void bindComparisonOperator()
          Test the type compatability of the operands and set the type info for this node.
 ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          Bind this comparison operator.
 ValueNode changeToCNF(boolean underTopAndNode)
          Finish putting an expression into conjunctive normal form.
(package private)  ValueNode eliminateNots(boolean underNotNode)
          Eliminate NotNodes in the current query block.
 ValueNode genSQLJavaSQLTree()
          generate a SQL->Java->SQL conversion tree above the left and right operand of this Binary Operator Node if needed.
(package private)  boolean getBetweenSelectivity()
          Return whether or not to use the between selectivity for this node.
 boolean getForQueryRewrite()
          Was this node generated in a query rewrite?
(package private)  BinaryOperatorNode getNegation(ValueNode leftOperand, ValueNode rightOperand)
          Negate the comparison.
 void init(java.lang.Object leftOperand, java.lang.Object rightOperand, java.lang.Object operator, java.lang.Object methodName)
          Initializer for a BinaryComparisonOperatorNode
 ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)
          Preprocess an expression tree.
(package private)  void setBetweenSelectivity()
          Use between selectivity when calculating the selectivity.
 void setForQueryRewrite(boolean val)
          This node was generated as part of a query rewrite.
 
Methods inherited from class org.apache.derby.impl.sql.compile.BinaryOperatorNode
accept, bindXMLExists, categorize, constantExpression, generateExpression, getLeftOperand, getOrderableVariantType, getReceiverInterfaceName, getRightOperand, init, init, initializeResultField, isConstantExpression, printSubNodes, remapColumnReferencesToExpressions, setClause, setLeftOperand, setLeftRightInterfaceType, setMethodName, setOperator, setRightOperand, swapOperands, toString
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, checkIsBoolean, checkReliability, checkReliability, checkTopPredicatesForEqualsConditions, copyFields, genEqualsFalseTree, generate, generateFilter, genIsNullTree, 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, updatableByCursor, 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, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, referencesSessionSchema, resolveTableToSynonym, 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
 

Field Detail

forQueryRewrite

private boolean forQueryRewrite

betweenSelectivity

private boolean betweenSelectivity
Constructor Detail

BinaryComparisonOperatorNode

public BinaryComparisonOperatorNode()
Method Detail

init

public void init(java.lang.Object leftOperand,
                 java.lang.Object rightOperand,
                 java.lang.Object operator,
                 java.lang.Object methodName)
Initializer for a BinaryComparisonOperatorNode

Overrides:
init in class BinaryOperatorNode

setForQueryRewrite

public void setForQueryRewrite(boolean val)
This node was generated as part of a query rewrite. Bypass the normal comparability checks.


getForQueryRewrite

public boolean getForQueryRewrite()
Was this node generated in a query rewrite?


setBetweenSelectivity

void setBetweenSelectivity()
Use between selectivity when calculating the selectivity.


getBetweenSelectivity

boolean getBetweenSelectivity()
Return whether or not to use the between selectivity for this node.


bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         throws org.apache.derby.iapi.error.StandardException
Bind this comparison operator. All that has to be done for binding a comparison operator is to bind the operands, check the compatibility of the types, and set the result type to SQLBoolean.

Overrides:
bindExpression in class BinaryOperatorNode

bindComparisonOperator

public void bindComparisonOperator()
                            throws org.apache.derby.iapi.error.StandardException
Test the type compatability of the operands and 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.


preprocess

public ValueNode preprocess(int numTables,
                            FromList outerFromList,
                            SubqueryList outerSubqueryList,
                            PredicateList outerPredicateList)
                     throws org.apache.derby.iapi.error.StandardException
Preprocess an expression tree. We do a number of transformations here (including subqueries, IN lists, LIKE and BETWEEN) plus subquery flattening. NOTE: This is done before the outer ResultSetNode is preprocessed.

Overrides:
preprocess in class BinaryOperatorNode

eliminateNots

ValueNode eliminateNots(boolean underNotNode)
                  throws org.apache.derby.iapi.error.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

getNegation

BinaryOperatorNode getNegation(ValueNode leftOperand,
                               ValueNode rightOperand)
                         throws org.apache.derby.iapi.error.StandardException
Negate the comparison.


changeToCNF

public ValueNode changeToCNF(boolean underTopAndNode)
                      throws org.apache.derby.iapi.error.StandardException
Finish putting an expression into conjunctive normal form. An expression tree in conjunctive normal form meets the following criteria: o If the expression tree is not null, the top level will be a chain of AndNodes terminating in a true BooleanConstantNode. o The left child of an AndNode will never be an AndNode. o Any right-linked chain that includes an AndNode will be entirely composed of AndNodes terminated by a true BooleanConstantNode. o The left child of an OrNode will never be an OrNode. o Any right-linked chain that includes an OrNode will be entirely composed of OrNodes terminated by a false BooleanConstantNode. o ValueNodes other than AndNodes and OrNodes are considered leaf nodes for purposes of expression normalization. In other words, we won't do any normalization under those nodes. In addition, we track whether or not we are under a top level AndNode. SubqueryNodes need to know this for subquery flattening.

Overrides:
changeToCNF in class ValueNode

genSQLJavaSQLTree

public ValueNode genSQLJavaSQLTree()
                            throws org.apache.derby.iapi.error.StandardException
Description copied from class: BinaryOperatorNode
generate a SQL->Java->SQL conversion tree above the left and right operand of this Binary Operator Node if needed. Subclasses can override the default behavior.

Overrides:
genSQLJavaSQLTree in class BinaryOperatorNode