|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
An Aggregation aggregates a set of values into one value.
It is used, via a Aggregate.Call, in an Aggregate relational operator.
To help you understand the terminology, here are some analogies: an
Aggregation is analogous to a OJMethod, whereas
a Aggregate.Call is analogous to a MethodCall. AggregationExtender has no direct
analog in Java: it is more like a function object in JScript.
For user-defined aggregates, use you should generally use AggregationExtender; writing a new Aggregation is a
complicated task, akin to writing a new relational operator (Rel).
AggregationExtender| Method Summary | |
boolean |
canMerge()
Whether this aggregation can merge together two accumulators. |
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. |
| Method Detail |
public OJClass getReturnType()
public OJClass[] getParameterTypes()
public boolean canMerge()
count can (you just add the accumulators);
avg and Nth cannot.
public Expression implementStart(Implementor implementor,
Rel rel,
int[] args)
sum(x), this looks like new
saffron.runtime.Holder.int_Holder(0).
public Expression implementStartAndNext(Implementor implementor,
Rel rel,
int[] args)
sum(x), this looks like new
saffron.runtime.Holder.int_Holder(x).
public void implementNext(Implementor implementor,
Rel rel,
Expression accumulator,
int[] args)
implementor'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.
implementor - 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)
implementor'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 canMerge() returns
true.
implementor - 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)
sum(x), this looks like
((saffron.runtime.Holder.int_Holder) accumulator).value.
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||