This involves actually two steps.
1) SQL to MAL connection
Example: CREATE AGGREGATE myagg (b INTEGER) RETURNS INTEGER EXTERNAL
NAME mymodule.meagg;
2) MAL to C connection
module mymodule;
command meagg(b:bat[:oid,:int], e:bat[:oid,:int]) :bat[:oid,:int]
address meagg_c_implementation
comment "Meagg mal aggregate";
str meagg_c(int *retid, int *bid, int *eid) {
/* C code here */
}
The code is quite self-explanatory I think.
Hope that helps,
Babis
On Tue, Nov 19, 2013 at 7:16 PM, Alastair McKinley
Hi Babis,
Thanks for your guidance that is very useful indeed!
I am not entirely clear on how a specific SUM aggregate query maps to a particular MAL signature/C function in aggr.mal.
For example, if I had
CREATE TABLE T ( int a, float b, float c );
SELECT a,SUM(b+c) FROM T GROUP BY a;
What MAL function signature would this result in?
Best regards and thanks,
Alastair ________________________________________ From: users-list
on behalf of Charalampos Nikolaou Sent: 19 November 2013 14:15 To: Communication channel for MonetDB users Subject: Re: User Defined Aggregations in MonetDB? Hi Alastair,
sure you can do that. You can have a look at the following files:
http://dev.monetdb.org/hg/MonetDB/file/af39d1a659f6/monetdb5/modules/kernel/... http://dev.monetdb.org/hg/MonetDB/file/af39d1a659f6/monetdb5/modules/kernel/... http://dev.monetdb.org/hg/MonetDB/file/af39d1a659f6/gdk/gdk_aggr.c
This article should be helpful and informative as well to you that explains how aggregates and grouping works inside MonetDB: http://www.monetdb.org/content/internal-changes-feb2013-release
Regards, Babis
On Tue, Nov 19, 2013 at 3:42 PM, Alastair McKinley
wrote: Dear all,
I was wondering if it is possible to build a User Defined Aggregation in MonetDB.
For example, rather than do SUM(myfunction(a,b)) I would like to do MYAGG(a,b) where MYAGG internally holds a small buffer of a and b values so that they can be calculated in a batch fashion with a high performance batch implementation of the function.
Could MYAGG be implemented in C?
Best regards,
Alastair
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list _______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list