UDAF Class Overview

You create your UDAF by subclassing two classes defined by the Vertica SDK: AggregateFunction and AggregateFunctionFactory.

AggregateFunction

The AggregateFunction class performs the aggregation. It computes values on each database node where relevant data is stored and then combines the results from the nodes. You must implement the following methods:

Important: The aggregate() function might not operate on the complete input set all at once. For this reason, initAggregate() must be idempotent.

The AggregateFunction class also provides optional methods that you can implement to allocate and free resources: setup() and destroy(). You should use these methods to allocate and deallocate resources that you do not allocate through the UDAF API (see Allocating Resources for UDxs for details).

AggregateFunctionFactory

The AggregateFunctionFactory class specifies metadata information such as the argument and return types of your aggregate function. It also instantiates your AggregateFunction subclass. Your subclass must implement the following methods:

Vertica uses this data when you call the CREATE AGGREGATE FUNCTION SQL statement to add the function to the database catalog.