Changeset: d1d1edf6022f for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d1d1edf6022f Added Files: monetdb5/extras/rdf/rdf_shredder.c Removed Files: monetdb5/extras/rdf/rdf_shredder.mx Branch: default Log Message:
Use hg rename. diffs (truncated from 413 to 300 lines): diff --git a/monetdb5/extras/rdf/rdf_shredder.mx b/monetdb5/extras/rdf/rdf_shredder.c rename from monetdb5/extras/rdf/rdf_shredder.mx rename to monetdb5/extras/rdf/rdf_shredder.c --- a/monetdb5/extras/rdf/rdf_shredder.mx +++ b/monetdb5/extras/rdf/rdf_shredder.c @@ -1,29 +1,25 @@ -@/ -The contents of this file are subject to the MonetDB Public License -Version 1.1 (the "License"); you may not use this file except in -compliance with the License. You may obtain a copy of the License at -http://www.monetdb.org/Legal/MonetDBLicense - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is the MonetDB Database System. - -The Initial Developer of the Original Code is CWI. -Portions created by CWI are Copyright (C) 1997-July 2008 CWI. -Copyright August 2008-2013 MonetDB B.V. -All Rights Reserved. -@ - -@f rdf_shredder - -@c /* - * @a L.Sidirourgos + * The contents of this file are subject to the MonetDB Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.monetdb.org/Legal/MonetDBLicense + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is the MonetDB Database System. + * + * The Initial Developer of the Original Code is CWI. + * Portions created by CWI are Copyright (C) 1997-July 2008 CWI. + * Copyright August 2008-2013 MonetDB B.V. + * All Rights Reserved. +*/ +/* + * (author) L.Sidirourgos * - * @+ Shredder for RDF Documents + * Shredder for RDF Documents */ #include "monetdb_config.h" #include "mal_exception.h" @@ -97,24 +93,22 @@ typedef struct parserData { } parserData; /* - * @- * The (fatal) errors and warnings produced by the raptor parser are handled * by the next three message handler functions. */ -@= raptor_exception -@1->exception++; -@1->exceptionMsg = @2; -raptor_parse_abort (@1->rparser); +#define raptor_exception(P,M) \ +P->exception++;\ +P->exceptionMsg = M;\ +raptor_parse_abort (P->rparser); -@= rdf_parser_handler static void -@1Handler (void *user_data, raptor_locator* locator, +fatalHandler (void *user_data, raptor_locator* locator, const char *message) { parserData *pdata = (parserData *) user_data; - pdata->@1Msg = GDKstrdup(message); - mnstr_printf(GDKout, "rdflib: @1:%s\n", pdata->@1Msg); - pdata->@1++; + pdata->fatalMsg = GDKstrdup(message); + mnstr_printf(GDKout, "rdflib: fatal:%s\n", pdata->fatalMsg); + pdata->fatal++; /* check for a valid locator object and only then use it */ if (locator != NULL) { @@ -124,69 +118,64 @@ static void } } -@ -@c -@:rdf_parser_handler(fatal)@ -@:rdf_parser_handler(error)@ -@:rdf_parser_handler(warning)@ +errorHandler (void *user_data, raptor_locator* locator, + const char *message) +{ + parserData *pdata = (parserData *) user_data; + pdata->errorMsg = GDKstrdup(message); + mnstr_printf(GDKout, "rdflib: error:%s\n", pdata->errorMsg); + pdata->error++; + + /* check for a valid locator object and only then use it */ + if (locator != NULL) { + pdata->line = locator->line; + pdata->column = locator->column; + } else { + } +} + +warningHandler (void *user_data, raptor_locator* locator, + const char *message) +{ + parserData *pdata = (parserData *) user_data; + pdata->warningMsg = GDKstrdup(message); + mnstr_printf(GDKout, "rdflib: warning:%s\n", pdata->warningMsg); + pdata->warning++; + + /* check for a valid locator object and only then use it */ + if (locator != NULL) { + pdata->line = locator->line; + pdata->column = locator->column; + } else { + } +} + /* - * @- * The raptor parser needs to register a callback function that handles one triple * at a time. Function rdf_parser_triple_handler() does exactly this. */ -@= rdf_insert -#ifdef _TKNZR_H - @:rdf_tknzr_insert(@2)@ -#else - @:rdf_BUNappend_unq(@1, @2)@ -#endif - -@= rdf_BUNappend_unq_1 -bun = BUNfnd(BATmirror(@1),(ptr)@2); -if (bun == BUN_NONE) { - if (@1->T->hash && BATcount(@1) > 4 * @1->T->hash->mask) { - HASHdestroy(@1); - BAThash(BATmirror(@1), 2*BATcount(@1)); - } - bun = (BUN) ((@1)->hseqbase + (@1)->batCount); - @1 = BUNappend(@1, (ptr)@2, TRUE); - if (@1 == NULL) { - @:raptor_exception(pdata, "could not append in@1")@ - } -} else { - bun = (@1)->hseqbase + bun; +#define rdf_BUNappend_unq(X,Y)\ +bun = BUNfnd(BATmirror(X),(ptr)Y);\ +if (bun == BUN_NONE) {\ + if (BATcount(X) > 4 * X->T->hash->mask) {\ + HASHdestroy(X);\ + BAThash(BATmirror(X), 2*BATcount(X));\ + }\ + bun = (BUN) X->batCount;\ + X = BUNappend(X, (ptr)Y, TRUE);\ + if (X == NULL) {\ + raptor_exception(pdata, "could not append");\ + }\ } -@= rdf_BUNappend_unq -bun = BUNfnd(BATmirror(@1),(ptr)@2); -if (bun == BUN_NONE) { - if (BATcount(@1) > 4 * @1->T->hash->mask) { - HASHdestroy(@1); - BAThash(BATmirror(@1), 2*BATcount(@1)); - } - bun = (BUN) @1->batCount; - @1 = BUNappend(@1, (ptr)@2, TRUE); - if (@1 == NULL) { - @:raptor_exception(pdata, "could not append in@1")@ - } +#define rdf_BUNappend(X,Y) \ +{X = BUNappend(X, Y, TRUE);}\ +if (X == NULL) {\ + raptor_exception(pdata, "could not append");\ } -@= rdf_tknzr_insert -{ - str t = @1; - TKNZRappend(&bun,&t); -} - -@= rdf_BUNappend -{@1 = BUNappend(@1, @2, TRUE);} -if (@1 == NULL) { - @:raptor_exception(pdata, "could not append in@1")@ -} - -@ -@c static void tripleHandler(void* user_data, const raptor_statement* triple) { @@ -196,32 +185,67 @@ tripleHandler(void* user_data, const rap if (triple->subject_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE || triple->subject_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) { - @:rdf_insert(graph[MAP_LEX],(str)triple->subject)@ - @:rdf_BUNappend(graph[S_sort], &bun)@ +#ifdef _TKNZR_H +{ + str t = (str)triple->subject; + TKNZRappend(&bun,&t); +} +#else + rdf_BUNappend_unq(graph[MAP_LEX], (str)triple->sibject); +#endif + rdf_BUNappend(graph[S_sort], &bun); bun = BUN_NONE; } else { - @:raptor_exception(pdata, "could not determine type of subject")@ + raptor_exception(pdata, "could not determine type of subject"); } if (triple->predicate_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE) { - @:rdf_insert(graph[MAP_LEX],(str)triple->predicate)@ - @:rdf_BUNappend(graph[P_sort], &bun)@ +#ifdef _TKNZR_H +{ + str t = (str)triple->predicate; + TKNZRappend(&bun,&t); +} +#else + rdf_BUNappend_unq(pdate, (str)triple->predicate); +#endif + rdf_BUNappend(graph[P_sort], &bun); bun = BUN_NONE; } else { - @:raptor_exception(pdata, "could not determine type of property")@ + raptor_exception(pdata, "could not determine type of property"); } if (triple->object_type == RAPTOR_IDENTIFIER_TYPE_RESOURCE || triple->object_type == RAPTOR_IDENTIFIER_TYPE_ANONYMOUS) { - @:rdf_insert(graph[MAP_LEX],(str)triple->object)@ - @:rdf_BUNappend(graph[O_sort], &bun)@ +#ifdef _TKNZR_H +{ + str t = (str)triple->object; + TKNZRappend(&bun,&t); +} +#else + rdf_BUNappend_unq(graph[MAP_LEX], (str)triple->object); +#endif + rdf_BUNappend(graph[O_sort], &bun); bun = BUN_NONE; } else if (triple->object_type == RAPTOR_IDENTIFIER_TYPE_LITERAL) { - @:rdf_BUNappend_unq_1(graph[MAP_LEX], triple->object)@ - @:rdf_BUNappend(graph[O_sort], &bun)@ + bun = BUNfnd(BATmirror(graph[MAP_LEX]),(ptr)triple->object); + if (bun == BUN_NONE) { + if (graph[MAP_LEX]->T->hash && BATcount(graph[MAP_LEX]) > 4 * graph[MAP_LEX]->T->hash->mask) { + HASHdestroy(graph[MAP_LEX]); + BAThash(BATmirror(graph[MAP_LEX]), 2*BATcount(graph[MAP_LEX])); + } + bun = (BUN) ((graph[MAP_LEX])->hseqbase + (graph[MAP_LEX])->batCount); + graph[MAP_LEX] = BUNappend(graph[MAP_LEX], (ptr)triple->object, TRUE); + if (graph[MAP_LEX] == NULL) { + raptor_exception(pdata, "could not append ingraph[MAP_LEX]"); + } + } else { + bun = (graph[MAP_LEX])->hseqbase + bun; + } + + rdf_BUNappend(graph[O_sort], &bun); bun = BUN_NONE; } else { - @:raptor_exception(pdata, "could not determine type of object")@ + raptor_exception(pdata, "could not determine type of object"); } pdata->tcount++; @@ -230,19 +254,8 @@ tripleHandler(void* user_data, const rap } /* - * @- * Function RDFParser() is the entry point to parse an RDF document. */ -@= set_handlers -/* set callback handler for triples */ -raptor_set_statement_handler (@1, @2, tripleHandler); -/* set message handlers */ -raptor_set_fatal_error_handler (@1, @2, fatalHandler); -raptor_set_error_handler (@1, @2, errorHandler); -raptor_set_warning_handler (@1, @2, warningHandler); - _______________________________________________ checkin-list mailing list [email protected] https://www.monetdb.org/mailman/listinfo/checkin-list
