|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--saffron.rel.ExtenderAggregation
ExtenderAggregation is an aggregation which works by
instantiating a user-defined aggregation (AggregationExtender), as opposed to generating custom code.
Two bugs with the current implementation of implementStart(saffron.opt.Implementor, saffron.rel.Rel, int[])
etc. First, the aggregation expression should be evaluated only once -- when
the query starts -- and stored in a variable. I guess it should be added to
the environment holding the query.
Second, we pass real expressions as the values of the dummy arguments to
implementStart(saffron.opt.Implementor, saffron.rel.Rel, int[]) and implementResult(openjava.ptree.Expression). This is inefficient,
but moreover, it is conceivable that the expressions will not be valid in
the scope where start and result are executed.
| Field Summary | |
(package private) OJClass |
aggClazz
|
(package private) Expression |
aggExp
|
(package private) OJMethod |
aggregateMethod
|
(package private) OJClass[] |
argTypes
|
(package private) OJMethod |
mergeMethod
|
(package private) OJMethod |
nextMethod
|
(package private) OJMethod |
resultMethod
|
(package private) OJMethod |
startMethod
|
| Constructor Summary | |
(package private) |
ExtenderAggregation(Expression aggExp,
Environment env,
OJClass[] argTypes)
|
| Method Summary | |
boolean |
canMerge()
Whether this aggregation can merge together two accumulators. |
private static OJMethod |
findMethod(OJClass aggClazz,
String name,
OJClass[] argTypes,
int extra,
OJClass desiredType,
boolean fail)
|
OJClass[] |
getParameterTypes()
|
OJClass |
getReturnType()
|
void |
implementMerge(Implementor implementor,
Rel rel,
Expression accumulator,
Expression otherAccumulator)
Generates (into the current statement list, gleaned by calling implementor's Implementor.getStatementList() method) code to merge two
accumulators. |
void |
implementNext(Implementor implementor,
Rel rel,
Expression accumulator,
int[] args)
Generates (into the current statement list, gleaned by calling implementor's Implementor.getStatementList() method) the piece of code
which gets called each time an extra row is seen. |
Expression |
implementResult(Expression accumulator)
Generates the expression which gets called when a total is complete. |
Expression |
implementStart(Implementor implementor,
Rel rel,
int[] args)
Generates the expression which gets called when a new total is created. |
Expression |
implementStartAndNext(Implementor implementor,
Rel rel,
int[] args)
Generates code to create a new total and to add the first value. |
static boolean |
matches(OJClass aggClazz,
OJClass[] argTypes)
Returns whether this aggregation has an overloading which matches the given name and argument types. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
Expression aggExp
OJClass aggClazz
OJClass[] argTypes
OJMethod aggregateMethod
OJMethod startMethod
OJMethod nextMethod
OJMethod mergeMethod
OJMethod resultMethod
| Constructor Detail |
ExtenderAggregation(Expression aggExp,
Environment env,
OJClass[] argTypes)
| Method Detail |
public static boolean matches(OJClass aggClazz,
OJClass[] argTypes)
private static OJMethod findMethod(OJClass aggClazz,
String name,
OJClass[] argTypes,
int extra,
OJClass desiredType,
boolean fail)
public OJClass getReturnType()
getReturnType in interface Aggregationpublic OJClass[] getParameterTypes()
getParameterTypes in interface Aggregationpublic boolean canMerge()
Aggregationcount can (you just add the accumulators);
avg and Nth cannot.
canMerge in interface Aggregation
public Expression implementStart(Implementor implementor,
Rel rel,
int[] args)
Aggregationsum(x), this looks like new
saffron.runtime.Holder.int_Holder(0).
implementStart in interface Aggregation
public Expression implementStartAndNext(Implementor implementor,
Rel rel,
int[] args)
Aggregationsum(x), this looks like new
saffron.runtime.Holder.int_Holder(x).
implementStartAndNext in interface Aggregation
public void implementNext(Implementor implementor,
Rel rel,
Expression accumulator,
int[] args)
Aggregationimplementor's Implementor.getStatementList() method) the piece of code
which gets called each time an extra row is seen. For
sum(x), this looks like
((saffron.runtime.Holder.int_Holder) accumulator).value +=
x.
implementNext in interface Aggregationimplementor - a callback object which knows how to generate thingsrel - the relational expression which is generating this codeaccumulator - the expression which holds the totalargs - the ordinals of the fields of the child row which are
arguments to this aggregation
public void implementMerge(Implementor implementor,
Rel rel,
Expression accumulator,
Expression otherAccumulator)
Aggregationimplementor's Implementor.getStatementList() method) code to merge two
accumulators. For sum(x), this looks like
((saffron.runtime.Holder.int_Holder) accumulator).value +=
((saffron.runtime.Holder.int_Holder) other).value.
The method is only called if Aggregation.canMerge() returns
true.
implementMerge in interface Aggregationimplementor - a callback object which knows how to generate thingsrel - the relational expression which is generating this codeaccumulator - the expression which holds the totalotherAccumulator - accumulator to merge inpublic Expression implementResult(Expression accumulator)
Aggregationsum(x), this looks like
((saffron.runtime.Holder.int_Holder) accumulator).value.
implementResult in interface Aggregation
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||