/***** ** Toma cada uno de las tripletas del archivo y las descompone ** va guardando en la BD. *****/ static void save_triple(void *user, raptor_statement *triple) { rdf_database db = (rdf_database)user; char *s = raptor_uri_to_string(triple->subject->value.uri); char *p = raptor_uri_to_string(triple->predicate->value.uri); char *o; if(triple->object->type == 1) o = raptor_uri_to_string(triple->object->value.uri); else o = triple->object->value.literal.string; // con 100000 y persondata50.rdf tengo la mitad de la bd isomorfa if(db->n == 17000) { raptor_parser_parse_abort(rdf_parser); } else rdf_database_add_triple(db, s, p, o); count++; }
static void to_ntriples_log_handler(void *data, raptor_log_message *message) { raptor_parser *parser = (raptor_parser*)data; switch(message->level) { case RAPTOR_LOG_LEVEL_FATAL: case RAPTOR_LOG_LEVEL_ERROR: fprintf(stderr, "%s: Error - ", program); raptor_locator_print(message->locator, stderr); fprintf(stderr, " - %s\n", message->text); raptor_parser_parse_abort(parser); error_count++; break; case RAPTOR_LOG_LEVEL_WARN: fprintf(stderr, "%s: Warning - ", program); raptor_locator_print(message->locator, stderr); fprintf(stderr, " - %s\n", message->text); warning_count++; break; case RAPTOR_LOG_LEVEL_NONE: case RAPTOR_LOG_LEVEL_TRACE: case RAPTOR_LOG_LEVEL_DEBUG: case RAPTOR_LOG_LEVEL_INFO: fprintf(stderr, "%s: Unexpected %s message - ", program, raptor_log_level_get_label(message->level)); raptor_locator_print(message->locator, stderr); fprintf(stderr, " - %s\n", message->text); break; } }
static int raptor_guess_parse_chunk(raptor_parser* rdf_parser, const unsigned char *buffer, size_t len, int is_end) { raptor_guess_parser_context* guess_parser = (raptor_guess_parser_context*)rdf_parser->context; if(guess_parser->do_guess) { const unsigned char *identifier = NULL; const char *name; guess_parser->do_guess = 0; if(rdf_parser->base_uri) identifier = raptor_uri_as_string(rdf_parser->base_uri); name = raptor_world_guess_parser_name(rdf_parser->world, NULL, guess_parser->content_type, buffer, len, identifier); if(!name) { raptor_parser_error(rdf_parser, "Failed to guess parser from content type '%s'", guess_parser->content_type ? guess_parser->content_type : "(none)"); raptor_parser_parse_abort(rdf_parser); if(guess_parser->parser) { raptor_free_parser(guess_parser->parser); guess_parser->parser = NULL; } return 1; } else { #if defined(RAPTOR_DEBUG) && RAPTOR_DEBUG > 1 RAPTOR_DEBUG2("Guessed parser name '%s'\n", name); #endif /* If there is an existing guessed parser factory present and * it's different from the wanted parser, free it */ if(guess_parser->parser) { raptor_parser_factory* factory = raptor_world_get_parser_factory(rdf_parser->world, name); if(guess_parser->parser->factory != factory) { raptor_free_parser(guess_parser->parser); guess_parser->parser = NULL; } } if(!guess_parser->parser) { guess_parser->parser = raptor_new_parser(rdf_parser->world, name); if(!guess_parser->parser) return 1; } /* copy any user data to the grddl parser */ if(raptor_parser_copy_user_state(guess_parser->parser, rdf_parser)) return 1; if(raptor_parser_parse_start(guess_parser->parser, rdf_parser->base_uri)) return 1; } } /* now we can pass on calls to internal guess_parser */ return raptor_parser_parse_chunk(guess_parser->parser, buffer, len, is_end); }