saffron
Class BuiltinAggregation.Sum
java.lang.Object
|
+--saffron.BuiltinAggregation
|
+--saffron.BuiltinAggregation.Sum
- All Implemented Interfaces:
- Aggregation
- Enclosing class:
- BuiltinAggregation
- static class BuiltinAggregation.Sum
- extends BuiltinAggregation
Sum
is an aggregator which returns the sum of the values
which go into it. It has precisely one argument of numeric type
(int
, long
, float
,
double
), and the result is the same type.
Methods inherited from class saffron.BuiltinAggregation |
count, count, count, count, create, implementMerge, implementStartAndNext, lookup, max, max, max, min, min, min, sum, sum |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
type
private OJClass type
BuiltinAggregation.Sum
BuiltinAggregation.Sum(OJClass type)
getName
String getName()
- Specified by:
getName
in class BuiltinAggregation
canMerge
public boolean canMerge()
- Description copied from interface:
Aggregation
- Whether this aggregation can merge together two
accumulators.
count
can (you just add the accumulators);
avg
and Nth
cannot.
- Specified by:
canMerge
in interface Aggregation
- Overrides:
canMerge
in class BuiltinAggregation
getReturnType
public OJClass getReturnType()
getStartParameterTypes
public OJClass[] getStartParameterTypes()
getParameterTypes
public OJClass[] getParameterTypes()
implementStart
public Expression implementStart(Implementor implementor,
Rel rel,
int[] args)
- Description copied from interface:
Aggregation
- Generates the expression which gets called when a new total is
created. For
sum(x)
, this looks like new
saffron.runtime.Holder.int_Holder(0)
.
implementNext
public void implementNext(Implementor implementor,
Rel rel,
Expression accumulator,
int[] args)
- Description copied from interface:
Aggregation
- 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. For
sum(x)
, this looks like
((saffron.runtime.Holder.int_Holder) accumulator).value +=
x
.
- Parameters:
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
implementResult
public Expression implementResult(Expression accumulator)
- Description copied from interface:
Aggregation
- Generates the expression which gets called when a total is complete. For
sum(x)
, this looks like
((saffron.runtime.Holder.int_Holder) accumulator).value
.