Thanks for answer. I used:

command BitAnd(Cell1:str,Cell2:str):flt
address UDFBitAnd
comment "Compare bag of words";

and it did not give me any errors, but when I launch monetdb "mclient -u monetdb -d voc", I get this error:


ParseException:SQLparser:!42000!syntax error, unexpected '[' in: "-- This Source Code Form is subject to the terms of the Mozilla Public
-- Licens"

I looked into license.txt and README, but there are no "[" there. Any ideas?


On Tue, Mar 22, 2016 at 5:08 PM, Stefan Manegold <Stefan.Manegold@cwi.nl> wrote:

As the error message says,
instead of "chr", the MAL parser expects a valid MAL type.

As opposed to the (wrong) documentation at
https://monetdb.org/Documentation/Manuals/MonetDB/MAL/Types ,
MAL (and all of MonetDB for that matter)
does not support any "chr" (or single-byte single-character) type.

See also (new) bug report #3959:
https://www.monetdb.org/bugzilla/show_bug.cgi?id=3959

SQL type "CHAR[ACTER] '(' length ')'" (just like SQL types
"VARCHAR '(' length ')' | CHARACTER VARYING '(' length ')'" and
"TEXT | STRING | CLOB | CHARACTER LARGE OBJECT")
all map to MAL type ":str", which in turn maps to (MonetDB) C type "str",
which in turn is defined as "char *".

Hope this helps.

Stefan

----- On Mar 22, 2016, at 4:50 PM, Shmagi Kavtaradze kavtaradze.s@gmail.com wrote:

> I am trying to write a C User Defined Function. It works in Neatbeans. What I
> want is, to take value from cells, insert them in text or char array and
> compare each corresponding array position to each other. As values I will have
> "1"s and "0s". E.g "101010100011". THe code I wrote in udf.c:
>
> /* Comparing bag of words */
>
> char
> BitAnd(char Cell1[], char Cell2[])
> {
> Cell1[10000];
> Cell2[10000];
> int counter;
> float result;
> int strlen = sizeof(Cell1)/sizeof(Cell1[0])-1;
> int i;
> for (i=0; i < strlen; i++) {
> if (Cell1[i] == Cell2[i]) {
> counter++;
> }
> }
>
> result = (float)counter / strlen;
>
>
> }
>
> /* MAL wrapper */
> char
> UDFBitAnd(char Cell1[], char Cell2[])
> {
> /* assert calling sanity */
> assert(Cell1[] != NULL && Cell2[] != NULL);
> return MAL_SUCCEED;
>
> }
>
>
> In udf.mal I have:
>
> command BitAnd(Cell1:chr,Cell2:chr):flt
> address UDFBitAnd
> comment "Compare bag of words";
>
> In 80_udf.sql:
>
> -- Comparing bag of words
> create function BitAnd(Cell1[] char, Cell2[] char)
> returns float external name udf.BitAnd;
>
> I compiled Monetdb, but when I try to connect with "monetdb" to db it gives me
> error. In the log file I found:
>
> MSG voc[18857]: !SyntaxException:parseError:command
> BitAnd(Cell1:chr,Cell2:chr):flt
> MSG voc[18857]: !SyntaxException:parseError: ^Type identifier expected
> MSG voc[18857]: !SyntaxException:parseError:command
> BitAnd(Cell1:chr,Cell2:chr):flt
> MSG voc[18857]: !SyntaxException:parseError: ^',' expected
> MSG merovingian[8780]: database 'voc' (18857) has exited with exit status 0
> MSG merovingian[8780]: database 'voc' has shut down
> ERR merovingian[8780]: client error: database 'voc' started up, but failed to
> open up a communication channel
>
>
>
> _______________________________________________
> users-list mailing list
> users-list@monetdb.org
> https://www.monetdb.org/mailman/listinfo/users-list

--
| Stefan.Manegold@CWI.nl | DB Architectures   (DA) |
| www.CWI.nl/~manegold/  | Science Park 123 (L321) |
| +31 (0)20 592-4212     | 1098 XG Amsterdam  (NL) |
_______________________________________________
users-list mailing list
users-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/users-list