On 4 Nov 2018, at 18:16, Renato Marroquín Mogrovejo <renatoj.marroquin@gmail.com> wrote:Hey Mark,Thanks for the reply, however I am still having trouble with it.So I am trying to replicate the example of creating C UDF from [https://www.monetdb.org/blog/JIT_C_C%252B%252B_UDFs_in_MonetDB], the one that returns a table. My MAL function is as follows:function user.s8_1():void;X_5:int := sql.mvc();(X_8:bat[:int], X_12:bat[:dbl]) := capi.eval(nil:ptr, false:bit, "{\n#include <math.h>\n size_t j;\n size_t count = arg1.data[0];\n\n i->initialize(i, count);\n d->initialize(d, count);\n for(j = 0; j < count; j++) {\n i->data[j] = j;\n d->data[j] = round(j > 0 ? 42.0 / j : 42.0);\n }\n};", 5);barrier X_87:bit := language.dataflow();X_14:bat[:str] := bat.new(nil:str);X_20:bat[:int] := bat.new(nil:int);X_18:bat[:int] := bat.new(nil:int);X_17:bat[:str] := bat.new(nil:str);X_16:bat[:str] := bat.new(nil:str);X_21:bat[:str] := bat.append(X_14, ".L2");X_23:bat[:str] := bat.append(X_16, "i");X_25:bat[:str] := bat.append(X_17, "int");X_27:bat[:int] := bat.append(X_18, 32);X_29:bat[:int] := bat.append(X_20, 0);X_31:bat[:str] := bat.append(X_21, ".L2");X_32:bat[:str] := bat.append(X_23, "d");X_34:bat[:str] := bat.append(X_25, "double");X_36:bat[:int] := bat.append(X_27, 53);X_38:bat[:int] := bat.append(X_29, 0);exit X_87:bit;sql.resultSet(X_31, X_32, X_34, X_36, X_38, X_8, X_12);end user.s8_1;But I still get: error: ‘arg1’ undeclared (first use in this function)Other related question is regarding output parameters names? In the C code, they are named <i> and <d> and this also throws an undeclared error.Btw, is there a way to get the UDF definition, i.e., the pointer as expected? I maybe that would be an easier solution?Thanks again!Best,Renato M._______________________________________________El dom., 4 nov. 2018 a las 15:42, Mark Raasveldt (<m.raasveldt@cwi.nl>) escribió:Hey Renato,_______________________________________________Just like the pyapi and rapi functions, the first argument is a pointer to the SQL function definition. This pointer is used to retrieve the argument names that were defined in the SQL layer. On the MAL layer you can simply pass the argument "nil:ptr”. This will result in the variables being called “arg1”, “arg2”, etc… See the pyapi MAL tests for more information (sql/backends/monet5/UDF/pyapi/Tests/*.malC).Regards,MarkOn 4 Nov 2018, at 11:53, Renato Marroquín Mogrovejo <renatoj.marroquin@gmail.com> wrote:_______________________________________________Hi all,I am trying to use the following patten from MAL[1]pattern eval(fptr:ptr,cpp:bit,expr:str,arg:any...):any...However, I am not sure how I should create the first parameter <fptr:ptr> from MAL. I am just trying to be able to call a C-UDF from MAL. From capi.c, it would seem that it is the client's context but I don't know how to get a handle of that.Any pointers are highly appreciated.Thanks!Renato M.
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