A typical aggregate function (non-decomposable) should implement the processing methods aggregateRow, getFinalValue, and reset, in addition to those related to custom context, in the following structure:
struct UdfAggregatorFunctionPointers { void* customContext; void (*releaseCustomContext)( void* customContext ); SqlmrErrorH (*aggregateRow)( SqlmrTaskContextH taskContext, void* customContext, SqlmrRowViewH input ) SQLMR_ERROR_RESULT; SqlmrErrorH (*getFinalValue)( SqlmrTaskContextH taskContext, void* customContext, SqlmrValueHolderH outValueHolder ) SQLMR_ERROR_RESULT; SqlmrErrorH (*reset)( SqlmrTaskContextH taskContext, void* customContext ) SQLMR_ERROR_RESULT; };
The following table describes the member variables or methods used in the structure above:
Member Name | Type | Description |
---|---|---|
customContext | variable | Points to a scratch store that holds temporary data needed by the function. For example, this storage may contain running values or partial values for the function. |
releaseCustomContext | method | Releases the resources held by customContext. This function must be set only if customContext is set. |
aggregateRow | method | Performs processing on all rows. |
getFinalValue | method | Returns to final output. |
reset | method | Resets the aggregate to its initial state. |