|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--saffron.rel.Rel
A Rel
is a relational expression. It is NOT an Expression
.
If this type of relational expression has some particular rules, it
should implement the public static method register(saffron.Planner)
.
Nested Class Summary | |
private static class |
Rel.PlanImplementor
|
Field Summary | |
protected Cluster |
cluster
|
private String |
corelVariable
The variable by which to refer to rows from this relational expression, as correlating expressions; null if this expression is not correlated on. |
protected String |
digest
A short description of this relational expression's type, inputs, and other properties. |
(package private) static Rel[] |
emptyArray
|
private RelEnvironment |
env
|
protected int |
id
unique id of this object -- for debugging |
(package private) static int |
nextId
generator for id values |
Type |
rowType
cached type of this relational expression |
Constructor Summary | |
Rel(Cluster cluster)
Creates a Rel . |
Method Summary | |
void |
childrenAccept(RelVisitor visitor)
|
abstract Object |
clone()
|
protected String |
computeDigest()
Computes the digest. |
Cost |
computeSelfCost(Planner planner)
Returns the cost of this plan (not including children). |
protected abstract Type |
deriveRowType()
|
void |
explain(PlanWriter pw)
|
Expression[] |
getChildExps()
Returns an array of this Rel 's child expressions (not
including the inputs returned by getInputs() . |
Cluster |
getCluster()
|
CallingConvention |
getConvention()
Returns a value from CallingConvention . |
String |
getCorelVariable()
|
RelEnvironment |
getEnvironment()
|
int |
getId()
|
Rel |
getInput(int i)
Get the i th input. |
Rel[] |
getInputs()
Returns an array of this Rel 's inputs. |
String |
getOrCreateCorelVariable()
Returns a variable with which to reference the current row of this relational expression as a correlating variable. |
Environment |
getParentEnv()
|
String |
getQualifier()
|
Query |
getQuery()
|
String |
getRelTypeName()
Returns the name of this Rel 's class, sans package name,
for use in explain(saffron.PlanWriter) . |
double |
getRows()
Returns an estimate of the number of rows this relational expression will return. |
Type |
getRowType()
Returns the type of the rows returned by this relational expression. |
protected Table |
getTable()
If this relational expression represents an access to a table, returns that table, otherwise returns null. |
OJClass |
getType(Expression exp)
Returns the type of an expression in this Rel 's
environment. |
Set |
getVariablesStopped()
Returns the names of variables which are set in this relational expression but also used and therefore not available to parents of this relational expression. |
Object |
implement(Implementor implementor,
int ordinal)
Create a plan for this expression according to a calling convention. |
Expression |
implementExp(Expression exp,
Plan[] plans)
|
Expression[] |
implementExps(Expression[] exps,
Plan[] plans)
|
Rel |
implementFieldAccess(Implementor implementor,
String fieldName)
Burrows into a synthetic record and returns the underlying relation which provides the field called fieldName . |
Expression |
implementSelf(Implementor implementor)
Returns a Java expression which yields the current row of this relational expression. |
boolean |
isAccessTo(Table table)
Returns whether this relational expression is an access to table . |
boolean |
isDistinct()
Returns whether the same value will not come out twice. |
void |
onRegister(Planner planner)
This method is called just before the expression is registered. |
String |
recomputeDigest()
Computes the digest, assigns it, and returns it. |
static void |
register(Planner planner)
Registers any special rules specific to this kind of relational expression. |
void |
registerCorelVariable(String corelVariable)
|
void |
replaceInput(int ordinalInParent,
Rel p)
Replaces the ordinalInParent th input. |
void |
setCorelVariable(String corelVariable)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected String digest
computeDigest()
, assigned by onRegister(saffron.Planner)
, returned by
toString()
.
protected int id
static int nextId
id
values
public Type rowType
private RelEnvironment env
protected Cluster cluster
private String corelVariable
static final Rel[] emptyArray
Constructor Detail |
public Rel(Cluster cluster)
Rel
.
Method Detail |
public abstract Object clone()
clone
in class Object
public int getId()
public Environment getParentEnv()
public RelEnvironment getEnvironment()
public Query getQuery()
public Cluster getCluster()
public static void register(Planner planner)
The planner calls this method this first time that it sees a
relational expression of this class. The derived class should call
Planner.addRule(saffron.opt.Rule)
for each rule, and then call
register(saffron.Planner)
on its base class.
public OJClass getType(Expression exp)
Rel
's
environment.
public final Type getRowType()
public Rel[] getInputs()
Rel
's inputs. If there are no
inputs, returns an empty array, not null
.
public void replaceInput(int ordinalInParent, Rel p)
ordinalInParent
th input. You must
override this method if you override getInputs()
.
public Expression[] getChildExps()
Rel
's child expressions (not
including the inputs returned by getInputs()
. If there are no
child expressions, returns an empty array, not null
.
public void explain(PlanWriter pw)
public final String getRelTypeName()
Rel
's class, sans package name,
for use in explain(saffron.PlanWriter)
. For example, for a
saffron.ArrayRel.ArrayReader
, returns "ArrayReader".
public String getQualifier()
protected String computeDigest()
public String recomputeDigest()
public void childrenAccept(RelVisitor visitor)
protected abstract Type deriveRowType()
public boolean isAccessTo(Table table)
table
.
protected Table getTable()
public Rel getInput(int i)
i
th input.
public String getOrCreateCorelVariable()
public void registerCorelVariable(String corelVariable)
public String getCorelVariable()
public void setCorelVariable(String corelVariable)
public Set getVariablesStopped()
By default, returns the empty set. Derived classes may override this method.
public boolean isDistinct()
false
, derived classes should override.
public void onRegister(Planner planner)
public String toString()
toString
in class Object
public double getRows()
public Cost computeSelfCost(Planner planner)
public Object implement(Implementor implementor, int ordinal)
implementor
- implementorordinal
- indicates our position in the pre-, in- and postfix walk
over the tree; ordinal
is -1 when called from the
parent, and i
when called from the
i
th child.
UnsupportedOperationException
- if this expression cannot be
implementedpublic Expression implementSelf(Implementor implementor)
Rel.PlanImplementor
the first time a piece
of Java code wants to refer to this relation. The implementor then
uses this expression to initialize a variable.
If no code needs to refer to this relation, then the expression is never generated. This prevents generating useless code like
.Dummy_12f614.Ojp_1 oj_var8 = new Dummy_12f614.Ojp_1();
Implementor#bind(Rel,Rel)
public Rel implementFieldAccess(Implementor implementor, String fieldName)
fieldName
.
public CallingConvention getConvention()
CallingConvention
.
public Expression implementExp(Expression exp, Plan[] plans)
public Expression[] implementExps(Expression[] exps, Plan[] plans)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |