User Defined Aggregations in MonetDB?
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
Hi, Check the list, this was discussed some times in previous messages. In a nutshell, yes, it can be done. On 11/19/2013 01: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
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
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
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
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
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
Hi Babis,
Thanks again for the example steps to creating an aggregate.
Is there a typo in your code or is the C function supposed to take int* parameters?
I assumed it would be BATs like the MAL function signature?
Best regards and thanks,
Alastair
________________________________________
From: users-list
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
users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
Actually, there is no typo there. You have to check out gdk.h which is
one of the first things you have to do in order to find out the
MonetDB API exposed to programmers by the MonetDB kernel (GDK). The
parameters correspond to identifiers of BAT structures that you have
to look them up and take the actual BAT.
Cheers,
Babis
On Wed, Nov 20, 2013 at 12:40 PM, Alastair McKinley
Hi Babis,
Thanks again for the example steps to creating an aggregate.
Is there a typo in your code or is the C function supposed to take int* parameters?
I assumed it would be BATs like the MAL function signature?
Best regards and thanks,
Alastair ________________________________________ From: users-list
on behalf of Charalampos Nikolaou Sent: 19 November 2013 17:32 To: Communication channel for MonetDB users Subject: Re: User Defined Aggregations in MonetDB? 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
wrote: 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
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
participants (3)
-
Alastair McKinley
-
Charalampos Nikolaou
-
Miguel Ping