|
||||||||||
| 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 AggregateRel.Call, in an AggregateRel relational operator.
To help you understand the terminology, here are some analogies: an
Aggregation is analogous to a OJMethod, whereas
a AggregateRel.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 (SaffronRel).
AggregationExtender| Method Summary | |
boolean |
canMerge()
Whether this aggregation can merge together two accumulators. |
SaffronType[] |
getParameterTypes(SaffronTypeFactory typeFactory)
|
SaffronType |
getReturnType(SaffronTypeFactory typeFactory)
|
void |
implementMerge(RelImplementor implementor,
SaffronRel rel,
Expression accumulator,
Expression otherAccumulator)
Generates (into the current statement list, gleaned by calling implementor's RelImplementor.getStatementList() method) code to
merge two accumulators. |
void |
implementNext(RelImplementor implementor,
SaffronRel rel,
Expression accumulator,
int[] args)
Generates (into the current statement list, gleaned by calling implementor's RelImplementor.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(RelImplementor implementor,
SaffronRel rel,
int[] args)
Generates the expression which gets called when a new total is created. |
Expression |
implementStartAndNext(RelImplementor implementor,
SaffronRel rel,
int[] args)
Generates code to create a new total and to add the first value. |
| Method Detail |
public SaffronType[] getParameterTypes(SaffronTypeFactory typeFactory)
public SaffronType getReturnType(SaffronTypeFactory typeFactory)
public boolean canMerge()
count can (you just add the accumulators);
avg and Nth cannot.
public void implementMerge(RelImplementor implementor,
SaffronRel rel,
Expression accumulator,
Expression otherAccumulator)
implementor's RelImplementor.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 in
public void implementNext(RelImplementor implementor,
SaffronRel rel,
Expression accumulator,
int[] args)
implementor's RelImplementor.getStatementList() method) the piece of code
which gets called each time an extra row is seen. For
sum(x), this looks like
((net.sf.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 aggregationpublic Expression implementResult(Expression accumulator)
sum(x), this looks like
((saffron.runtime.Holder.int_Holder) accumulator).value.
public Expression implementStart(RelImplementor implementor,
SaffronRel rel,
int[] args)
sum(x), this looks like new
saffron.runtime.Holder.int_Holder(0).
public Expression implementStartAndNext(RelImplementor implementor,
SaffronRel rel,
int[] args)
sum(x), this looks like new
saffron.runtime.Holder.int_Holder(x).
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||