Package com.mckoi.database
Class QueryPlan.RangeSelectNode
- java.lang.Object
-
- com.mckoi.database.QueryPlan.SingleQueryPlanNode
-
- com.mckoi.database.QueryPlan.RangeSelectNode
-
- All Implemented Interfaces:
QueryPlanNode,java.io.Serializable,java.lang.Cloneable
- Enclosing class:
- QueryPlan
public static class QueryPlan.RangeSelectNode extends QueryPlan.SingleQueryPlanNode
The node for performing a simple indexed query on a single column of the child node. Finds the set from the child node that matches the range.The given Expression object must conform to a number of rules. It may reference only one column in the child node. It must consist of only simple mathemetical and logical operators (<, >, =, <>, >=, <=, AND, OR). The left side of each mathematical operator must be a variable, and the right side must be a constant (parameter subsitution or correlated value). For example; (col > 10 AND col < 100) OR col > 1000 OR col == 10
Breaking any of these rules will mean the range select can not happen.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private ExpressionexpressionA simple expression that represents the range to select.(package private) static longserialVersionUID-
Fields inherited from class com.mckoi.database.QueryPlan.SingleQueryPlanNode
child
-
-
Constructor Summary
Constructors Constructor Description RangeSelectNode(QueryPlanNode child, Expression exp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcalcRange(QueryContext context, DataTableColumnDef field, SelectableRangeSet range, Expression exp)Calculates a list of SelectableRange objects that represent the range of the expression.java.lang.Objectclone()Deep clone.private java.util.ArrayListcreateAndList(java.util.ArrayList list, Expression exp)Given an Expression, this will return a list of expressions that can be safely executed as a set of 'and' operations.java.util.ArrayListdiscoverCorrelatedVariables(int level, java.util.ArrayList list)Default implementation that discovers correlated variables for the given offset level.java.util.ArrayListdiscoverTableNames(java.util.ArrayList list)Default implementation delegates responsibility to child.Tableevaluate(QueryContext context)Evaluates the node and returns the result as a Table.java.lang.StringtitleString()private voidupdateRange(QueryContext context, SelectableRangeSet range, DataTableColumnDef field, Expression e)Updates a range with the given expression.-
Methods inherited from class com.mckoi.database.QueryPlan.SingleQueryPlanNode
child, debugString
-
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
expression
private Expression expression
A simple expression that represents the range to select. See the class comments for a description for how this expression must be formed.
-
-
Constructor Detail
-
RangeSelectNode
public RangeSelectNode(QueryPlanNode child, Expression exp)
-
-
Method Detail
-
createAndList
private java.util.ArrayList createAndList(java.util.ArrayList list, Expression exp)Given an Expression, this will return a list of expressions that can be safely executed as a set of 'and' operations. For example, an expression of 'a=9 and b=c and d=2' would return the list; 'a=9','b=c', 'd=2'.If non 'and' operators are found then the reduction stops.
-
updateRange
private void updateRange(QueryContext context, SelectableRangeSet range, DataTableColumnDef field, Expression e)
Updates a range with the given expression.
-
calcRange
private void calcRange(QueryContext context, DataTableColumnDef field, SelectableRangeSet range, Expression exp)
Calculates a list of SelectableRange objects that represent the range of the expression.
-
evaluate
public Table evaluate(QueryContext context)
Description copied from interface:QueryPlanNodeEvaluates the node and returns the result as a Table. The VariableResolver resolves any outer variables
-
discoverTableNames
public java.util.ArrayList discoverTableNames(java.util.ArrayList list)
Description copied from class:QueryPlan.SingleQueryPlanNodeDefault implementation delegates responsibility to child.- Specified by:
discoverTableNamesin interfaceQueryPlanNode- Overrides:
discoverTableNamesin classQueryPlan.SingleQueryPlanNode
-
discoverCorrelatedVariables
public java.util.ArrayList discoverCorrelatedVariables(int level, java.util.ArrayList list)Description copied from class:QueryPlan.SingleQueryPlanNodeDefault implementation that discovers correlated variables for the given offset level.- Specified by:
discoverCorrelatedVariablesin interfaceQueryPlanNode- Overrides:
discoverCorrelatedVariablesin classQueryPlan.SingleQueryPlanNode
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionDescription copied from class:QueryPlan.SingleQueryPlanNodeDeep clone.- Specified by:
clonein interfaceQueryPlanNode- Overrides:
clonein classQueryPlan.SingleQueryPlanNode- Throws:
java.lang.CloneNotSupportedException
-
titleString
public java.lang.String titleString()
- Overrides:
titleStringin classQueryPlan.SingleQueryPlanNode
-
-