I have written a code in c, it works and now I want to implement it in Monetdb.
1) should I append the code in /sql/backends/monet5/UDF/udf.c file?
2) I have gone through udf.c, but still not sure how implement my c code there. I do not know C, just wanted to implement simple code. Can anyone help me adapting it to UDF?
I want a function like BAnd(a.chunk, b.chunk), and instead of {"10101011"} in foo and bar, I want values of the columns.
#include<stdio.h>
main (){
const char foo[] = {"10101011"};
const char bar[] = {"01110111"};
int counter;
float result;
int strlen = sizeof(foo)/sizeof(foo[0])-1;
for (int i=0; i < strlen; i++) {
if (foo[i] == bar[i]) {
counter++;
}
}
result = (float)counter / strlen;
printf("%d::%d::%f", counter, strlen, result);
return 0;
}