org.h2.api
Interface Aggregate

All Known Implementing Classes:
TestFunctions.MedianStringType, TestSpatial.TableEnvelope

public interface Aggregate

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
 void add(java.lang.Object value)
          This method is called once for each row.
 int getInternalType(int[] inputTypes)
          This method must return the H2 data type, Value, of the aggregate function, given the H2 data type of the input data.
 java.lang.Object getResult()
          This method returns the computed aggregate value.
 void init(java.sql.Connection conn)
          This method is called when the aggregate function is used.
 

Method Detail

init

void init(java.sql.Connection conn)
          throws java.sql.SQLException
This method is called when the aggregate function is used. A new object is created for each invocation.

Parameters:
conn - a connection to the database
Throws:
java.sql.SQLException

getInternalType

int getInternalType(int[] inputTypes)
                    throws java.sql.SQLException
This method must return the H2 data type, 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 - the H2 data type of the parameters,
Returns:
the H2 data type of the result
Throws:
java.sql.SQLException - if the number/type of parameters passed is incorrect

add

void add(java.lang.Object value)
         throws java.sql.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 - the value(s) for this row
Throws:
java.sql.SQLException

getResult

java.lang.Object getResult()
                           throws java.sql.SQLException
This method returns the computed aggregate value.

Returns:
the aggregated value
Throws:
java.sql.SQLException