|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
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
.
lookup
Expression lookup(int offset,
Rel input,
boolean foo,
String varName)
convertQueryToRel
Rel convertQueryToRel(QueryExpression queryExp)
- Converts a
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.
convertFromExpToRel
Rel convertFromExpToRel(Expression exp)
- Converts an expression into a relational expression. For example,
an array becomes an
ExpressionReader
. Leaf nodes are
registered in leaves
.
- Parameters:
exp
- the expression to convert
- Returns:
- the equivalent relational expression
removeSubqueries
Expression removeSubqueries(Expression exp)
- Goes through an expression looking for sub-queries (
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:
select from dept
where dept.location.equals("SF") && exists (
select from emp
where emp.deptno == dept.deptno && emp.gender.equals("F"))
becomes
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:
select from emp
where emp.deptno in (
select dept.deptno from dept where dept.location.equals("SF"))
&& emp.gender.equals("F")
becomes
select 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")
Optimization #1: If the 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")
- Parameters:
exp
- Expression
- Returns:
- expression with subqueries removed
Overview
Package
Class
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD