Top Description Methods
org.h2.api

public Interface Aggregate

Known Direct Implementers
org.h2.schema.UserAggregate.AggregateWrapper
Imports
java.sql.Connection, .SQLException

A user-defined aggregate function needs to implement this interface. The class must be public and must have a public non-argument constructor.

Method Summary

Modifier and TypeMethod and Description
public void
add(Object
the value(s) for this row
value
)

This method is called once for each row.

public int

Returns:

the H2 data type of the result
getInternalType
(int[]
the H2 data type of the parameters,
inputTypes
)

This method must return the H2 data type, org.h2.value.Value, of the aggregate function, given the H2 data type of the input data.

public Object

Returns:

the aggregated value
getResult
()

This method returns the computed aggregate value.

public default void
init(Connection
a connection to the database
conn
)

This method is called when the aggregate function is used.

Method Detail

addback to summary
public void add(Object value) throws SQLException

This method is called once for each row. If the aggregate function is called with multiple parameters, those are passed as array.

Parameters
value:Object

the value(s) for this row

Exceptions
SQLException:
on failure
getInternalTypeback to summary
public int getInternalType(int[] inputTypes) throws SQLException

This method must return the H2 data type, org.h2.value.Value, of the aggregate function, given the H2 data type of the input data. The method should check here if the number of parameters passed is correct, and if not it should throw an exception.

Parameters
inputTypes:int[]

the H2 data type of the parameters,

Returns:int

the H2 data type of the result

Exceptions
SQLException:
if the number/type of parameters passed is incorrect
getResultback to summary
public Object getResult() throws SQLException

This method returns the computed aggregate value. This method must preserve previously added values and must be able to reevaluate result if more values were added since its previous invocation.

Returns:Object

the aggregated value

Exceptions
SQLException:
on failure
initback to summary
public default void init(Connection conn) throws SQLException

This method is called when the aggregate function is used. A new object is created for each invocation.

Parameters
conn:Connection

a connection to the database

Exceptions
SQLException:
on SQL exception