|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ValueNode
org.apache.derby.impl.sql.compile.BinaryOperatorNode
org.apache.derby.impl.sql.compile.BinaryComparisonOperatorNode
org.apache.derby.impl.sql.compile.BinaryRelationalOperatorNode
This class represents the 6 binary operators: LessThan, LessThanEquals, Equals, NotEquals, GreaterThan and GreaterThanEquals.
Field Summary | |
protected static int |
LEFT
|
protected static int |
NEITHER
|
private int |
operatorType
|
protected static int |
RIGHT
|
Fields inherited from class org.apache.derby.impl.sql.compile.BinaryComparisonOperatorNode |
|
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, 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 |
Fields inherited from interface org.apache.derby.impl.sql.compile.RelationalOperator |
EQUALS_RELOP, GREATER_EQUALS_RELOP, GREATER_THAN_RELOP, IS_NOT_NULL_RELOP, IS_NULL_RELOP, LESS_EQUALS_RELOP, LESS_THAN_RELOP, NOT_EQUALS_RELOP |
Constructor Summary | |
BinaryRelationalOperatorNode()
|
Method Summary | |
protected double |
booleanSelectivity(Optimizable optTable)
Return 50% if this is a comparison with a boolean column, a negative selectivity otherwise. |
protected int |
columnOnOneSide(Optimizable optTable)
Determine whether there is a column from the given table on one side of this operator, and if so, which side is it on? |
boolean |
compareWithKnownConstant(Optimizable optTable,
boolean considerParameters)
Return whether this operator compares the given Optimizable with a constant whose value is known at compile time. |
boolean |
equalsComparisonWithConstantExpression(Optimizable optTable)
Return whether this operator is an equality comparison of the given optimizable with a constant expression. |
void |
generateAbsoluteColumnId(MethodBuilder mb,
Optimizable optTable)
Generate the absolute column id for the ColumnReference that appears on one side of this RelationalOperator or the other, and that refers to the given table. |
void |
generateExpressionOperand(Optimizable optTable,
int columnPosition,
ExpressionClassBuilder acb,
MethodBuilder mb)
Check whether this RelationalOperator is a comparison of the given column with an expression. |
void |
generateNegate(MethodBuilder mb,
Optimizable optTable)
Generate an expression that evaluates to true if the result of the comparison should be negated. |
void |
generateOperator(MethodBuilder mb,
Optimizable optTable)
Generate the comparison operator for this RelationalOperator. |
void |
generateOrderedNulls(MethodBuilder mb)
Generate an expression that evaluates to true if this RelationalOperator uses ordered null semantics, false if it doesn't. |
void |
generateQualMethod(ExpressionClassBuilder acb,
MethodBuilder mb,
Optimizable optTable)
Generate the method to evaluate a Qualifier. |
void |
generateRelativeColumnId(MethodBuilder mb,
Optimizable optTable)
Generate the relative column id for the ColumnReference that appears on one side of this RelationalOperator or the other, and that refers to the given table. |
ValueNode |
genSQLJavaSQLTree()
generate a SQL->Java->SQL conversion tree above the left and right operand of this Binary Operator Node if needed. |
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)
Check whether this RelationalOperator is a comparison of the given column with an expression. |
ColumnReference |
getColumnOperand(Optimizable optTable)
Get the ColumnReference for the given table on one side of this RelationalOperator. |
ColumnReference |
getColumnOperand(Optimizable optTable,
int columnPosition)
Check whether this RelationalOperator is a comparison of the given column with an expression. |
DataValueDescriptor |
getCompareValue(Optimizable optTable)
Return an Object representing the known value that this relational operator is comparing to a column in the given Optimizable. |
ValueNode |
getExpressionOperand(int tableNumber,
int columnPosition)
Check whether this RelationalOperator is a comparison of the given column with an expression. |
(package private) BinaryOperatorNode |
getNegation(ValueNode leftOperand,
ValueNode rightOperand)
Returns the negation of this operator; negation of Equals is NotEquals. |
private int |
getNegationNode()
|
int |
getOperator()
Return the operator (as an int) for this RelationalOperator. |
int |
getOrderableVariantType(Optimizable optTable)
Return the variant type for the Qualifier's Orderable. |
java.lang.String |
getReceiverInterfaceName()
The methods generated for this node all are on Orderable. |
int |
getStartOperator(Optimizable optTable)
Get the start operator for a scan (at the store level) for this RelationalOperator. |
int |
getStopOperator(Optimizable optTable)
Get the stop operator for a scan (at the store level) for this RelationalOperator. |
RelationalOperator |
getTransitiveSearchClause(ColumnReference otherCR)
Return a relational operator which matches the current one but with the passed in ColumnReference as the (left) operand. |
private boolean |
implicitVarcharComparison()
Return whether or not this binary relational predicate requires an implicit (var)char conversion. |
void |
init(java.lang.Object leftOperand,
java.lang.Object rightOperand)
Initialize a query tree node. |
boolean |
isBinaryEqualsOperatorNode()
Returns true if this value node is a equals operator. |
boolean |
isQualifier(Optimizable optTable)
Return true if this operator can be compiled into a Qualifier for the given Optimizable table. |
boolean |
isRelationalOperator()
Returns true if this ValueNode is a relational operator. |
protected boolean |
keyColumnOnLeft(Optimizable optTable)
Return true if a key column for the given table is found on the left side of this operator, false if it is found on the right side of this operator. |
boolean |
optimizableEqualityNode(Optimizable optTable,
int columnNumber,
boolean isNullOkay)
Return true if the predicate represents an optimizable equality node. |
boolean |
orderedNulls()
Return true if this operator uses ordered null semantics |
double |
selectivity(Optimizable optTable)
return the selectivity of this predicate. |
boolean |
selfComparison(ColumnReference cr)
Check whether this RelationalOperator compares the given ColumnReference to any columns in the same table as the ColumnReference. |
protected boolean |
usefulStartKey(boolean columnOnLeft)
is this is useful start key? |
boolean |
usefulStartKey(Optimizable optTable)
Tell whether this relop is a useful start key for the given table. |
protected boolean |
usefulStopKey(boolean columnOnLeft)
|
boolean |
usefulStopKey(Optimizable optTable)
Tell whether this relop is a useful stop key for the given table. |
Methods inherited from class org.apache.derby.impl.sql.compile.BinaryComparisonOperatorNode |
bindComparisonOperator, bindExpression, changeToCNF, eliminateNots, getBetweenSelectivity, getForQueryRewrite, init, preprocess, setBetweenSelectivity, setForQueryRewrite |
Methods inherited from class org.apache.derby.impl.sql.compile.BinaryOperatorNode |
accept, bindXMLExists, categorize, constantExpression, generateExpression, getLeftOperand, getOrderableVariantType, 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, isBooleanFalse, isBooleanTrue, isCloneable, isParameterNode, putAndsOnTop, setDescriptor, setTransformed, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private int operatorType
protected static final int LEFT
protected static final int NEITHER
protected static final int RIGHT
Constructor Detail |
public BinaryRelationalOperatorNode()
Method Detail |
public void init(java.lang.Object leftOperand, java.lang.Object rightOperand)
QueryTreeNode
init
in class QueryTreeNode
public ColumnReference getColumnOperand(Optimizable optTable, int columnPosition)
RelationalOperator
getColumnOperand
in interface RelationalOperator
optTable
- An Optimizable for the base table the column is incolumnPosition
- The ordinal position of the column (one-based)
RelationalOperator.getColumnOperand(org.apache.derby.iapi.sql.compile.Optimizable, int)
public ColumnReference getColumnOperand(int tableNumber, int columnPosition)
RelationalOperator
getColumnOperand
in interface RelationalOperator
tableNumber
- The table number of the table in questioncolumnPosition
- The ordinal position of the column (one-based)
RelationalOperator.getColumnOperand(org.apache.derby.iapi.sql.compile.Optimizable, int)
public ColumnReference getColumnOperand(Optimizable optTable)
RelationalOperator
getColumnOperand
in interface RelationalOperator
RelationalOperator.getColumnOperand(org.apache.derby.iapi.sql.compile.Optimizable, int)
public ValueNode getExpressionOperand(int tableNumber, int columnPosition)
RelationalOperator
getExpressionOperand
in interface RelationalOperator
tableNumber
- The table number of the base table the column is incolumnPosition
- The ordinal position of the column (one-based)
RelationalOperator.getExpressionOperand(int, int)
public void generateExpressionOperand(Optimizable optTable, int columnPosition, ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
RelationalOperator
generateExpressionOperand
in interface RelationalOperator
optTable
- An Optimizable for the base table the column is incolumnPosition
- The ordinal position of the column (one-based)acb
- The ExpressionClassBuilder for the class we're buildingmb
- The method the expression will go into
StandardException
- Thrown on errorRelationalOperator.generateExpressionOperand(org.apache.derby.iapi.sql.compile.Optimizable, int, org.apache.derby.impl.sql.compile.ExpressionClassBuilder, org.apache.derby.iapi.services.compiler.MethodBuilder)
public boolean selfComparison(ColumnReference cr) throws StandardException
RelationalOperator
selfComparison
in interface RelationalOperator
cr
- The ColumnReference that is being compared to some
expression.
StandardException
- Thrown on errorRelationalOperator.selfComparison(org.apache.derby.impl.sql.compile.ColumnReference)
public boolean usefulStartKey(Optimizable optTable)
RelationalOperator
usefulStartKey
in interface RelationalOperator
optTable
- The Optimizable table for which we want to know
whether this is a useful start key.
RelationalOperator.usefulStartKey(org.apache.derby.iapi.sql.compile.Optimizable)
protected boolean keyColumnOnLeft(Optimizable optTable)
optTable
- The Optimizable table that we're looking for a key
column on.
protected int columnOnOneSide(Optimizable optTable)
optTable
- The Optimizable table that we're looking for a key
column on.
public boolean usefulStopKey(Optimizable optTable)
RelationalOperator
usefulStopKey
in interface RelationalOperator
optTable
- The Optimizable table for which we want to know
whether this is a useful stop key.
RelationalOperator.usefulStopKey(org.apache.derby.iapi.sql.compile.Optimizable)
public void generateAbsoluteColumnId(MethodBuilder mb, Optimizable optTable)
RelationalOperator
generateAbsoluteColumnId
in interface RelationalOperator
mb
- The method the generated code is to go intooptTable
- The optimizable table we're doing the scan on.RelationalOperator.generateAbsoluteColumnId(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)
public void generateRelativeColumnId(MethodBuilder mb, Optimizable optTable)
RelationalOperator
generateRelativeColumnId
in interface RelationalOperator
mb
- The method the generated code is to go intooptTable
- The optimizable table we're doing the scan on.RelationalOperator.generateRelativeColumnId(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)
private int getAbsoluteColumnPosition(Optimizable optTable)
optTable
- The Optimizable
public void generateQualMethod(ExpressionClassBuilder acb, MethodBuilder mb, Optimizable optTable) throws StandardException
RelationalOperator
generateQualMethod
in interface RelationalOperator
acb
- The ExpressionClassBuilder for the class we're buildingmb
- The method the generated code is to go intooptTable
- The Optimizable table the Qualifier will qualify
StandardException
- Thrown on errorpublic void generateOrderedNulls(MethodBuilder mb)
RelationalOperator
generateOrderedNulls
in interface RelationalOperator
mb
- The method the generated code is to go intoRelationalOperator.generateOrderedNulls(org.apache.derby.iapi.services.compiler.MethodBuilder)
public boolean orderedNulls()
RelationalOperator
orderedNulls
in interface RelationalOperator
RelationalOperator.orderedNulls()
public boolean isQualifier(Optimizable optTable) throws StandardException
RelationalOperator
isQualifier
in interface RelationalOperator
optTable
- The Optimizable table in question.
StandardException
- Thrown on errorRelationalOperator.isQualifier(org.apache.derby.iapi.sql.compile.Optimizable)
public int getOrderableVariantType(Optimizable optTable) throws StandardException
RelationalOperator
getOrderableVariantType
in interface RelationalOperator
optTable
- The Optimizable table the Qualifier will qualify
StandardException
- thrown on errorRelationalOperator.getOrderableVariantType(org.apache.derby.iapi.sql.compile.Optimizable)
public boolean compareWithKnownConstant(Optimizable optTable, boolean considerParameters)
RelationalOperator
compareWithKnownConstant
in interface RelationalOperator
RelationalOperator.compareWithKnownConstant(org.apache.derby.iapi.sql.compile.Optimizable, boolean)
public DataValueDescriptor getCompareValue(Optimizable optTable) throws StandardException
RelationalOperator
getCompareValue
in interface RelationalOperator
StandardException
- Thrown on errorRelationalOperator.getCompareValue(org.apache.derby.iapi.sql.compile.Optimizable)
protected double booleanSelectivity(Optimizable optTable)
public java.lang.String getReceiverInterfaceName()
getReceiverInterfaceName
in class BinaryOperatorNode
BinaryOperatorNode getNegation(ValueNode leftOperand, ValueNode rightOperand) throws StandardException
getNegation
in class BinaryComparisonOperatorNode
leftOperand
- The left operand of the comparison operatorrightOperand
- The right operand of the comparison operator
StandardException
- Thrown on errorprivate int getNegationNode()
protected boolean usefulStartKey(boolean columnOnLeft)
columnOnLeft
- is true if the column is the left hand side of the
binary operator.protected boolean usefulStopKey(boolean columnOnLeft)
RelationalOperator.usefulStopKey(org.apache.derby.iapi.sql.compile.Optimizable)
public int getStartOperator(Optimizable optTable)
RelationalOperator
getStartOperator
in interface RelationalOperator
optTable
- The optimizable table we're doing the scan on.
This parameter is so we can tell which side of
the operator the table's column is on.
RelationalOperator.getStartOperator(org.apache.derby.iapi.sql.compile.Optimizable)
public int getStopOperator(Optimizable optTable)
RelationalOperator
getStopOperator
in interface RelationalOperator
optTable
- The optimizable table we're doing the scan on.
This parameter is so we can tell which side of
the operator the table's column is on.
RelationalOperator.getStopOperator(org.apache.derby.iapi.sql.compile.Optimizable)
public void generateOperator(MethodBuilder mb, Optimizable optTable)
RelationalOperator
generateOperator
in interface RelationalOperator
mb
- The method the generated code is to go intooptTable
- The optimizable table we're doing the scan on.RelationalOperator.generateOperator(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)
public void generateNegate(MethodBuilder mb, Optimizable optTable)
RelationalOperator
generateNegate
in interface RelationalOperator
mb
- The method the generated code is to go intooptTable
- The Optimizable table the Qualifier will qualifyRelationalOperator.generateNegate(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)
public int getOperator()
RelationalOperator
getOperator
in interface RelationalOperator
RelationalOperator.getOperator()
public double selectivity(Optimizable optTable)
selectivity
in class ValueNode
public RelationalOperator getTransitiveSearchClause(ColumnReference otherCR) throws StandardException
RelationalOperator
getTransitiveSearchClause
in interface RelationalOperator
otherCR
- The ColumnReference for the new (left) operand.
StandardException
- Thrown on errorRelationalOperator.getTransitiveSearchClause(org.apache.derby.impl.sql.compile.ColumnReference)
public boolean equalsComparisonWithConstantExpression(Optimizable optTable)
RelationalOperator
equalsComparisonWithConstantExpression
in interface RelationalOperator
public boolean isRelationalOperator()
ValueNode
isRelationalOperator
in class ValueNode
ValueNode.isRelationalOperator()
public boolean isBinaryEqualsOperatorNode()
ValueNode
isBinaryEqualsOperatorNode
in class ValueNode
ValueNode.isRelationalOperator()
public boolean optimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay) throws StandardException
ValueNode
optimizableEqualityNode
in class ValueNode
optTable
- the table being optimized. Column reference must be from
this table.columnNumber
- the column number. One of the operands of this
predicate must be the column number specified by optTable/columnNumberisNullOkay
- if set to true we also consider IS NULL predicates;
otherwise consider only = predicates.
StandardException
ValueNode.optimizableEqualityNode(org.apache.derby.iapi.sql.compile.Optimizable, int, boolean)
private boolean implicitVarcharComparison() throws StandardException
StandardException
- Thrown on errorpublic ValueNode genSQLJavaSQLTree() throws StandardException
BinaryOperatorNode
genSQLJavaSQLTree
in class BinaryComparisonOperatorNode
StandardException
BinaryOperatorNode.genSQLJavaSQLTree()
|
Built on Tue 2006-10-10 19:23:47+0200, from revision exported | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |