|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An AggregationExtender
allows end-users to define their own
aggregate functions.
An aggregation extender supports one or more sets of argument types,
T. T can be a single type (such as String
or
int
), several types (such as String, int
), or
empty. For each set T, it declares 4 methods:
Object start(T dummy)
creates an accumulator
Object next(T dummy, Object accumulator)
adds a value to an
accumulator, and returns the accumulator
Object merge(T dummy, Object accumulator0, Object
accumulator1)
merges the contents of accumulator1
into
accumulator0
, and returns the accumulator
T2 result(T dummy, Object accumulator)
retrieves the result
from an accumulator
merge
method is actually optional. If it is not present,
ExtenderAggregation.canMerge()
returns
false
.)
Consider the query
Locale
locale = Locale.getDefault();Collator
collator = Collator.getInstance(locale); LocaleMin localeMin = new LocaleMin(collator); select {localeMin.aggregate(emp.name)} group by {emp.deptno} from emps as emp
Here T is String
, and so LocaleMin.start(String)
will be called when a group
starts, LocaleMin.next(String,Object)
on each
row, and so forth.
Note that the aggregation object is evaluated each time a group starts. If each department has its own locale, one could write
select {new LocaleMin(Collator.getInstance(emp.dept.locale)) .aggregate(emp.name) } group by {emp.dept} from emps as emp
Field Summary | |
static String |
METHOD_AGGREGATE
The name of the "aggregate" method. |
static String |
METHOD_MERGE
The name of the "merge" method. |
static String |
METHOD_NEXT
The name of the "next" method. |
static String |
METHOD_RESULT
The name of the "result" method. |
static String |
METHOD_START
The name of the "start" method. |
Field Detail |
public static final String METHOD_AGGREGATE
public static final String METHOD_START
public static final String METHOD_NEXT
public static final String METHOD_RESULT
public static final String METHOD_MERGE
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |