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

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.BinaryListOperatorNode
              extended byorg.apache.derby.impl.sql.compile.InListOperatorNode
All Implemented Interfaces:
Visitable

public final class InListOperatorNode
extends BinaryListOperatorNode

An InListOperatorNode represents an IN list.

Author:
Jerry Brenner

Field Summary
private  boolean isOrdered
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.BinaryListOperatorNode
leftInterfaceType, leftOperand, methodName, operator, receiver, rightInterfaceType, rightOperandList
 
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
InListOperatorNode()
           
 
Method Summary
(package private)  ValueNode eliminateNots(boolean underNotNode)
          Eliminate NotNodes in the current query block.
 void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
          Do code generation for this IN list operator.
 void generateStartStopKey(boolean isAsc, boolean isStartKey, ExpressionClassBuilder acb, MethodBuilder mb)
          Generate start/stop key for this IN list operator.
 void init(java.lang.Object leftOperand, java.lang.Object rightOperandList)
          Initializer for a InListOperatorNode
 ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)
          Preprocess an expression tree.
 double selectivity(Optimizable optTable)
          The selectivity for an "IN" predicate is generally very small.
 boolean selfReference(ColumnReference cr)
          See if this IN list operator is referencing the same table.
 java.lang.String toString()
          Convert this object to a String.
 
Methods inherited from class org.apache.derby.impl.sql.compile.BinaryListOperatorNode
accept, bindComparisonOperator, bindExpression, categorize, constantExpression, getLeftOperand, getOrderableVariantType, getRightOperandList, init, isConstantExpression, printSubNodes, remapColumnReferencesToExpressions, setClause, setLeftOperand, setRightOperandList
 
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, 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, 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

isOrdered

private boolean isOrdered
Constructor Detail

InListOperatorNode

public InListOperatorNode()
Method Detail

init

public void init(java.lang.Object leftOperand,
                 java.lang.Object rightOperandList)
Initializer for a InListOperatorNode

Overrides:
init in class QueryTreeNode
Parameters:
leftOperand - The left operand of the node
rightOperandList - The right operand list of the node

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.

Overrides:
toString in class BinaryListOperatorNode
Returns:
This object as a String

preprocess

public ValueNode preprocess(int numTables,
                            FromList outerFromList,
                            SubqueryList outerSubqueryList,
                            PredicateList outerPredicateList)
                     throws 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 BinaryListOperatorNode
Parameters:
numTables - Number of tables in the DML Statement
outerFromList - FromList from outer query block
outerSubqueryList - SubqueryList from outer query block
outerPredicateList - PredicateList from outer query block
Returns:
The modified expression
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

selfReference

public boolean selfReference(ColumnReference cr)
                      throws StandardException
See if this IN list operator is referencing the same table.

Parameters:
cr - The column reference.
Returns:
true if in list references the same table as in cr.
Throws:
StandardException - Thrown on error

selectivity

public double selectivity(Optimizable optTable)
The selectivity for an "IN" predicate is generally very small. This is an estimate applicable when in list are not all constants.

Overrides:
selectivity in class ValueNode

generateExpression

public void generateExpression(ExpressionClassBuilder acb,
                               MethodBuilder mb)
                        throws StandardException
Do code generation for this IN list operator.

Overrides:
generateExpression in class ValueNode
Parameters:
acb - The ExpressionClassBuilder for the class we're generating
mb - The MethodBuilder the expression will go into
Returns:
An Expression to evaluate this operator
Throws:
StandardException - Thrown on error

generateStartStopKey

public void generateStartStopKey(boolean isAsc,
                                 boolean isStartKey,
                                 ExpressionClassBuilder acb,
                                 MethodBuilder mb)
                          throws StandardException
Generate start/stop key for this IN list operator. Bug 3858.

Parameters:
isAsc - is the index ascending on the column in question
isStartKey - are we generating start key or not
acb - The ExpressionClassBuilder for the class we're generating
mb - The MethodBuilder the expression will go into
Returns:
nothing
Throws:
StandardException - Thrown on error

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

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