|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--saffron.rel.QueryInfo
A QueryInfo
holds all the information about a QueryExpression
while it is being translated into a collection of
Rel
s.
Those Rel
s will all belong to the same Cluster
,
but Cluster
is much simpler. Please put the stuff which is
only needed at translation time into QueryInfo
, and keep
Cluster
simple.
Field Summary | |
(package private) Cluster |
cluster
|
(package private) Environment |
env
|
(package private) SaffronQueryExpander |
expander
|
(package private) ArrayList |
leaves
|
(package private) QueryInfo |
parent
|
private Rel |
root
|
Constructor Summary | |
(package private) |
QueryInfo(QueryInfo parent,
Environment env,
SaffronQueryExpander expander,
Expression exp)
Creates a QueryInfo |
Method Summary | |
Expression |
convertExpToInternal(Expression exp)
Translates an expression into one which references only internal variables. |
Expression |
convertExpToInternal(Expression exp,
Rel[] inputs)
|
(package private) Rel |
convertFromExpToRel(Expression exp)
Converts an expression into a relational expression. |
Expression |
convertGroupExpToInternal(Expression exp,
Expression[] groups,
ExpressionList aggInputList,
Vector aggCallVector)
Translates an aggregate expression into one which references only variables. |
(package private) Rel |
convertQueryToRel(QueryExpression queryExp)
Converts a QueryExpression into a Rel . |
(package private) int |
countColumns(Rel rel)
Returns the number of columns in this input. |
(package private) static Cluster |
createCluster(QueryInfo queryInfo,
Environment env,
Expression exp)
|
private Rel |
findLeaf(Rel rel,
int count,
int[] seen,
ArrayList path,
int depth)
Returns the count th leaf (Rel which implements
a from-list item) below this one. |
(package private) Rel |
getRoot()
|
(package private) Expression |
lookup(int offset,
Rel[] inputs,
boolean foo,
String varName)
Creates an expression with which to reference expression |
(package private) Expression |
lookup(int offset,
Rel input,
boolean foo,
String varName)
|
(package private) Expression |
removeSubqueries(Expression exp)
Goes through an expression looking for sub-queries ( in
or exists ). |
(package private) void |
setRoot(Rel root)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
QueryInfo parent
Environment env
SaffronQueryExpander expander
ArrayList leaves
Cluster cluster
private Rel root
Constructor Detail |
QueryInfo(QueryInfo parent, Environment env, SaffronQueryExpander expander, Expression exp)
QueryInfo
env
- environment of the query that this expression was
contained in - gives us access to the from list of that
queryMethod Detail |
static Cluster createCluster(QueryInfo queryInfo, Environment env, Expression exp)
Rel getRoot()
void setRoot(Rel root)
public Expression convertExpToInternal(Expression exp)
exp
- expression to translate
public Expression convertExpToInternal(Expression exp, Rel[] inputs)
public Expression convertGroupExpToInternal(Expression exp, Expression[] groups, ExpressionList aggInputList, Vector aggCallVector)
aggList
, if they are not already present.
exp
- expression to translategroups
- expressions from the group by
clauseaggInputList
- expressions inside aggregations; expressions are
added to this list if an aggregate needs one and it is not presentaggCallVector
- calls to aggregates; Aggregate.Call
s are added to this list if they are needed
but are not presentprivate Rel findLeaf(Rel rel, int count, int[] seen, ArrayList path, int depth)
count
th leaf (Rel
which implements
a from-list item) below this one.
rel
- relation to start fromcount
- leaf number we wantseen
- seen[0]
contains the number of leaves we
have seen so farpath
- List containing the rel at each depthdepth
- Current depthint countColumns(Rel rel)
Expression lookup(int offset, Rel[] inputs, boolean foo, String varName)
expression,
whose offset in its from-list is offset
.
Expression lookup(int offset, Rel input, boolean foo, String varName)
Rel convertQueryToRel(QueryExpression queryExp)
QueryExpression
into a Rel
.
Capture occurs when a query is converted into relational
expressions. The scalar expressions in the query reference (a) rows
from their own query, (b) rows from an enclosing query, (c)
variables from the enclosing environment.
We have already dealt with (a), and we can leave environmental
references (c) as they are. So, we deal with references to rows in
this query now. References to queries inside or outside this query
will happen in due course.
Rel convertFromExpToRel(Expression exp)
ExpressionReader
. Leaf nodes are
registered in leaves
.
exp
- the expression to convert
Expression removeSubqueries(Expression exp)
in
or exists
). If it finds one, it joins the query to the
from clause, replaces the condition, and returns true.
Examples:exists
becomes a reference to a indicator
query:
becomesselect from dept where dept.location.equals("SF") && exists ( select from emp where emp.deptno == dept.deptno && emp.gender.equals("F"))
select from dept cross join ( select distinct from emp where emp.deptno == dept.deptno && emp.gender.equals("F")) where dept.location.equals("SF") && indicator != null
The reference to 'dept' from within a join query is illegal -- but we haven't de-correlated yet.
in
becomes a test to see whether an outer-joined
query met the join condition:
becomesselect from emp where emp.deptno in ( select dept.deptno from dept where dept.location.equals("SF")) && emp.gender.equals("F")
Optimization #1: If theselect from emp left join ( select dept.deptno from dept where dept.location.equals("SF")) q1 on emp.deptno == q1.deptno where q1 is not null && emp.gender.equals("F")
in
condition is
&&
ed into the where clause, then make the join
into a full join, and omit the condition. Hence,
select from emp join ( select dept.deptno from dept where dept.location.equals("SF")) q1 on emp.deptno == q1.deptno where emp.gender.equals("F")
exp
- Expression
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |