Overload operators for built-in aggregates
The following table shows the operators that you must
overload for each of the built-in aggregates. For example, if you
need only the SUM aggregate for a UDT, you need to overload only the plus() operator.
Aggregate | Required operators | Return type |
---|---|---|
AVG | plus(udt, udt), divide(udt, integer) | Return type of divide() |
COUNT | -- (no new operators required) | Integer |
COUNT DISTINCT | equal(udt,udt) | Boolean |
DISTINCT (or UNIQUE) | compare(udt, udt) | Boolean |
MAX | greaterthanorequal(udt, udt) | Boolean |
MIN | lessthanorequal(udt, udt) | Boolean |
RANGE | lessthanorequal(udt, udt), greaterthanorequal(udt, udt), minus(udt, udt) | Return type of minus() |
SUM | plus(udt, udt) | Return type of plus() |
STDEV | times(udt, udt), divide(udt, integer), plus(udt, udt), minus(udt, udt), sqrt(udt) | Return type of divide() |
VARIANCE | times(udt, udt), divide(udt, integer), plus(udt, udt), minus(udt, udt) | Return type of divide() |
The database server uses the compare() function for indexing as well as for DISTINCT and UNIQUE aggregations. However, the database server calls the equal() function to process COUNT DISTINCT. You must write the compare() function in C or in Java™.