static void rasqal_rowsource_sparql_xml_process(rasqal_rowsource_sparql_xml_context* con) { if(raptor_sequence_size(con->results_sequence) && con->variables_count > 0) return; /* do some parsing - need some results */ while(!raptor_iostream_read_eof(con->iostr)) { size_t read_len; read_len = raptor_iostream_read_bytes((char*)con->buffer, 1, FILE_READ_BUF_SIZE, con->iostr); if(read_len > 0) { RASQAL_DEBUG2("processing %d bytes\n", (int)read_len); raptor_sax2_parse_chunk(con->sax2, con->buffer, read_len, 0); con->locator.byte += read_len; } if(read_len < FILE_READ_BUF_SIZE) { /* finished */ raptor_sax2_parse_chunk(con->sax2, NULL, 0, 1); break; } /* end with variables sequence done AND at least one row */ if(con->variables_count > 0 && raptor_sequence_size(con->results_sequence) > 0) break; } }
/** * rasqal_new_rowsequence_rowsource: * @world: world object * @query: query object * @vt: variables table * @rows_seq: input sequence of #rasqal_row * @vars_seq: input sequence of #rasqal_variable for all rows in @rows_seq * * INTERNAL - create a new rowsource over a sequence of rows with given variables * * This uses the number of variables in @vt to set the rowsource size * (order size is always 0) and then checks that all the rows in the * sequence are the same. If not, construction fails and NULL is * returned. * * The @rows_seq and @vars_seq become owned by the new rowsource. * * Return value: new rowsource or NULL on failure */ rasqal_rowsource* rasqal_new_rowsequence_rowsource(rasqal_world *world, rasqal_query* query, rasqal_variables_table* vt, raptor_sequence* rows_seq, raptor_sequence* vars_seq) { rasqal_rowsequence_rowsource_context* con; int flags = 0; if(!world || !query || !vt || !rows_seq || !vars_seq) return NULL; if(!raptor_sequence_size(rows_seq) || !raptor_sequence_size(vars_seq)) return NULL; con = RASQAL_CALLOC(rasqal_rowsequence_rowsource_context*, 1, sizeof(*con)); if(!con) return NULL; con->seq = rows_seq; con->vars_seq = vars_seq; return rasqal_new_rowsource_from_handler(world, query, con, &rasqal_rowsequence_rowsource_handler, vt, flags); }
static int rasqal_rowsequence_rowsource_init(rasqal_rowsource* rowsource, void *user_data) { rasqal_rowsequence_rowsource_context* con; int rows_count; int i; con = (rasqal_rowsequence_rowsource_context*)user_data; con->offset = 0; con->failed = 0; /* adjust offset of every row */ rows_count = raptor_sequence_size(con->seq); for(i = 0; i < rows_count; i++) { rasqal_row* row; row = (rasqal_row*)raptor_sequence_get_at(con->seq, i); row->rowsource = rowsource; row->offset = i; } return 0; }
static int #else static void #endif rasqal_rowsource_groupby_tree_print_node(void *object, FILE *fh) { rasqal_groupby_tree_node* node = (rasqal_groupby_tree_node*)object; fputs("Group\n Key Sequence of literals: ", fh); if(node->literals) /* sequence of literals */ raptor_sequence_print(node->literals, fh); else fputs("None", fh); fputs("\n Value Sequence of rows:\n", fh); if(node->rows) { int i; int size = raptor_sequence_size(node->rows); /* sequence of rows */ for(i = 0; i < size; i++) { rasqal_row* row = (rasqal_row*)raptor_sequence_get_at(node->rows, i); fprintf(fh, " Row %d: ", i); rasqal_row_print(row, fh); fputc('\n', fh); } } else fputs("None\n", fh); #ifdef HAVE_RAPTOR2_API return 0; #endif }
static int rasqal_sort_rowsource_init(rasqal_rowsource* rowsource, void *user_data) { rasqal_query *query = rowsource->query; rasqal_sort_rowsource_context *con; con = (rasqal_sort_rowsource_context*)user_data; if(con->order_seq) con->order_size = raptor_sequence_size(con->order_seq); else { RASQAL_DEBUG1("No order conditions for sort rowsource - passing through"); con->order_size = -1; } con->map = NULL; if(con->order_size > 0 ) { /* make a row:NULL map in order to sort or do distinct * FIXME: should DISTINCT be separate? */ con->map = rasqal_engine_new_rowsort_map(con->distinct, query->compare_flags, con->order_seq); if(!con->map) return 1; } con->seq = NULL; return 0; }
/* * librdf_parser_raptor_namespace_handler - helper callback function for raptor RDF when a namespace is seen * @context: context for callback * @statement: raptor_statement * * Adds the statement to the list of statements. */ static void librdf_parser_raptor_namespace_handler(void* user_data, raptor_namespace *nspace) { librdf_parser_raptor_context* pcontext=(librdf_parser_raptor_context*)user_data; const unsigned char* prefix; unsigned char* nprefix; size_t prefix_length; librdf_uri* uri; int i; uri=(librdf_uri*)raptor_namespace_get_uri(nspace); if(!uri) return; for(i=0; i < raptor_sequence_size(pcontext->nspace_uris); i++) { librdf_uri* u=(librdf_uri*)raptor_sequence_get_at(pcontext->nspace_uris, i); if(librdf_uri_equals(uri, u)) return; } /* new namespace */ uri=librdf_new_uri_from_uri(uri); raptor_sequence_push(pcontext->nspace_uris, uri); prefix=raptor_namespace_get_counted_prefix(nspace, &prefix_length); if(prefix) { nprefix = LIBRDF_MALLOC(unsigned char*, prefix_length + 1); /* FIXME: what if nprefix alloc failed? now just pushes NULL to sequence */ if(nprefix) strncpy((char*)nprefix, (const char*)prefix, prefix_length+1); } else
static int raptor_avltree_iterator_next(raptor_avltree_iterator* iterator) { iterator->index++; return (iterator->index > raptor_sequence_size(iterator->tree->seq)); }
/* add a namespace */ static int raptor_dot_serializer_declare_namespace_from_namespace(raptor_serializer* serializer, raptor_namespace *nspace) { raptor_dot_context * context = (raptor_dot_context *)serializer->context; int i; for( i = 0 ; i < raptor_sequence_size(context->namespaces) ; i++ ) { raptor_namespace * ns; ns = (raptor_namespace *)raptor_sequence_get_at(context->namespaces, i); /* If prefix is already declared, ignore it */ if((!ns->prefix && !nspace->prefix) || (ns->prefix && nspace->prefix && !strcmp((const char*)ns->prefix, (const char*)nspace->prefix)) || (ns->uri && nspace->uri && raptor_uri_equals(ns->uri, nspace->uri)) ) return 1; } nspace = raptor_new_namespace_from_uri(context->nstack, nspace->prefix, nspace->uri, 0); if(!nspace) return 1; raptor_sequence_push(context->namespaces, nspace); return 0; }
/** * rasqal_rowsource_get_variable_offset_by_name: * @rowsource: rasqal rowsource * @name: variable name * * Get the offset of a variable into the list of variables * * Return value: offset or <0 if not present or on failure **/ int rasqal_rowsource_get_variable_offset_by_name(rasqal_rowsource *rowsource, const unsigned char* name) { int offset= -1; int i; if(!rowsource) return -1; rasqal_rowsource_ensure_variables(rowsource); if(!rowsource->variables_sequence) return -1; for(i=0; i < raptor_sequence_size(rowsource->variables_sequence); i++) { rasqal_variable* v; v = (rasqal_variable*)raptor_sequence_get_at(rowsource->variables_sequence, i); if(!strcmp(RASQAL_GOOD_CAST(const char*, v->name), RASQAL_GOOD_CAST(const char*, name))) { offset = i; break; } } return offset; }
static void raptor_dot_serializer_write_uri(raptor_serializer* serializer, raptor_uri* uri) { raptor_dot_context* context = (raptor_dot_context*)serializer->context; unsigned char* full = raptor_uri_as_string(uri); int i; for( i = 0 ; i < raptor_sequence_size(context->namespaces) ; i++ ) { raptor_namespace* ns = (raptor_namespace*)raptor_sequence_get_at(context->namespaces, i); const unsigned char* ns_uri_string; size_t ns_uri_string_len; ns_uri_string=raptor_uri_as_counted_string(ns->uri, &ns_uri_string_len); if(!strncmp((char*)full, (char*)ns_uri_string, ns_uri_string_len) ) { const unsigned char* prefix = raptor_namespace_get_prefix(ns); if(prefix) { raptor_iostream_write_string(serializer->iostream, prefix); raptor_iostream_write_byte(serializer->iostream, ':'); } raptor_iostream_write_string(serializer->iostream, full + ns_uri_string_len); return; } } raptor_iostream_write_string(serializer->iostream, full); }
static int rasqal_raptor_init_triples_source_common(rasqal_world* world, raptor_sequence* data_graphs, rasqal_query* rdf_query, void *factory_user_data, void *user_data, rasqal_triples_source *rts, rasqal_triples_error_handler handler1, rasqal_triples_error_handler2 handler2, unsigned int flags) { rasqal_raptor_triples_source_user_data* rtsc; raptor_parser *parser; int i; int rc = 0; rtsc = (rasqal_raptor_triples_source_user_data*)user_data; /* Max API version this triples source generates */ rts->version = 2; rts->init_triples_match = rasqal_raptor_init_triples_match; rts->triple_present = rasqal_raptor_triple_present; rts->free_triples_source = rasqal_raptor_free_triples_source; rts->support_feature = rasqal_raptor_support_feature; if(data_graphs) rtsc->sources_count = raptor_sequence_size(data_graphs); else /* No data graph - assume there is just a background graph */ rtsc->sources_count = 0; if(rtsc->sources_count) rtsc->source_literals = RASQAL_CALLOC(rasqal_literal**, rtsc->sources_count, sizeof(rasqal_literal*)); else
static int rasqal_write_sparql_bindings(sparql_writer_context* wc, raptor_iostream* iostr, rasqal_bindings* bindings) { raptor_iostream_counted_string_write("BINDINGS", 8, iostr); rasqal_query_write_sparql_select(wc, iostr, bindings->variables); raptor_iostream_counted_string_write(" {\n", 3, iostr); if(bindings->rows) { int i; for(i = 0; i < raptor_sequence_size(bindings->rows); i++) { rasqal_row* row; row = raptor_sequence_get_at(bindings->rows, i); raptor_iostream_counted_string_write(" ", 2, iostr); rasqal_write_sparql_row(wc, iostr, row); raptor_iostream_counted_string_write("\n", 1, iostr); } } raptor_iostream_counted_string_write("}\n", 2, iostr); return 0; }
static int rasqal_graph_rowsource_init(rasqal_rowsource* rowsource, void *user_data) { rasqal_graph_rowsource_context *con; raptor_sequence* seq; con = (rasqal_graph_rowsource_context*)user_data; seq = rasqal_query_get_data_graph_sequence(rowsource->query); if(!seq) return 1; con->dg_size = raptor_sequence_size(seq); con->finished = 0; con->dg_offset = -1; con->offset = 0; /* Do not care if finished at this stage (it is not an * error). rasqal_graph_rowsource_read_row() will deal with * returning NULL for an empty result. */ rasqal_graph_next_dg(con); return 0; }
/* Check the list to see if the node is a duplicate. If not, add it * to the list. */ static void raptor_dot_serializer_assert_node(raptor_serializer* serializer, raptor_term* assert_node) { raptor_dot_context* context = (raptor_dot_context*)serializer->context; raptor_sequence* seq = NULL; int i; /* Which list are we searching? */ switch(assert_node->type) { case RAPTOR_TERM_TYPE_URI: seq = context->resources; break; case RAPTOR_TERM_TYPE_BLANK: seq = context->bnodes; break; case RAPTOR_TERM_TYPE_LITERAL: seq = context->literals; break; case RAPTOR_TERM_TYPE_UNKNOWN: break; } for(i = 0 ; i < raptor_sequence_size(seq) ; i++ ) { raptor_term* node = (raptor_term*)raptor_sequence_get_at(seq, i); if(raptor_term_equals(node, assert_node)) return; } raptor_sequence_push(seq, raptor_term_copy(assert_node)); }
void raptor_print_subject(raptor_abbrev_subject* subject) { int i; unsigned char *subj; unsigned char *pred; unsigned char *obj; raptor_avltree_iterator* iter=NULL; /* Note: The raptor_abbrev_node field passed as the first argument for * raptor_statement_part_as_string() is somewhat arbitrary, since as * the data structure is designed, the first word in the value union * is what was passed as the subject/predicate/object of the * statement. */ subj = raptor_statement_part_as_string(subject->node->value.resource.uri, subject->node->type, NULL, NULL); if(subject->type) { obj=raptor_statement_part_as_string(subject->type->value.resource.uri, subject->type->type, subject->type->value.literal.datatype, subject->type->value.literal.language); fprintf(stderr,"[%s, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, %s]\n", subj, obj); RAPTOR_FREE(cstring, obj); } for(i=0; i < raptor_sequence_size(subject->elements); i++) { raptor_abbrev_node* o = raptor_sequence_get_at(subject->elements, i); if(o) { obj = raptor_statement_part_as_string(o->value.literal.string, o->type, o->value.literal.datatype, o->value.literal.language); fprintf(stderr,"[%s, [rdf:_%d], %s]\n", subj, i, obj); RAPTOR_FREE(cstring, obj); } } iter=raptor_new_avltree_iterator(subject->properties, NULL, NULL, 1); while(iter) { raptor_abbrev_node** nodes; nodes=(raptor_abbrev_node**)raptor_avltree_iterator_get(iter); if(!nodes) break; raptor_print_abbrev_po(stderr, nodes); if(raptor_avltree_iterator_next(iter)) break; } if(iter) raptor_free_avltree_iterator(iter); RAPTOR_FREE(cstring, subj); }
/** * rasqal_query_results_rewind: * @query_results: #rasqal_query_results query_results * * Rewind stored query results to start * * This requires rasqal_query_set_store_results() to be called before * query execution. * * Return value: non-0 if rewinding is not available when results are not stored **/ int rasqal_query_results_rewind(rasqal_query_results* query_results) { int size; int limit = -1; int offset = -1; rasqal_query* query; RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(query_results, rasqal_query_results, 1); if(!query_results->results_sequence) return 1; size = raptor_sequence_size(query_results->results_sequence); /* This may be NULL for a static query result */ query = query_results->query; if(query) { /* If the query failed, it remains failed */ if(query->failed) return 1; limit = rasqal_query_get_limit(query); offset = rasqal_query_get_offset(query); } /* reset to first result */ query_results->finished = (size == 0); if(query && !limit) query_results->finished = 1; if(!query_results->finished) { /* Reset to first result, index-1 into sequence of results */ query_results->result_count = 0; /* skip past any OFFSET */ if(query && offset > 0) { query_results->result_count += offset; if(query_results->result_count >= size) query_results->finished = 1; } } if(query_results->finished) query_results->result_count = 0; else { if(query && query->constructs) rasqal_query_results_update_bindings(query_results); } return 0; }
/* * rasqal_expression_evaluate_in_set: * @e: The expression to evaluate. * @eval_context: Evaluation context * * INTERNAL - Evaluate RASQAL_EXPR_IN and RASQAL_EXPR_NOT_IN (expr, * expr list) expression. * * Return value: A #rasqal_literal boolean value or NULL on failure. */ static rasqal_literal* rasqal_expression_evaluate_in_set(rasqal_expression *e, rasqal_evaluation_context *eval_context, int *error_p) { rasqal_world* world = eval_context->world; int size = raptor_sequence_size(e->args); int i; rasqal_literal* l1; int found = 0; l1 = rasqal_expression_evaluate2(e->arg1, eval_context, error_p); if(*error_p || !l1) goto failed; for(i = 0; i < size; i++) { rasqal_expression* arg_e; rasqal_literal* arg_literal; arg_e = (rasqal_expression*)raptor_sequence_get_at(e->args, i); arg_literal = rasqal_expression_evaluate2(arg_e, eval_context, error_p); if(!arg_literal) goto failed; found = (rasqal_literal_equals_flags(l1, arg_literal, eval_context->flags, error_p) != 0); #if RASQAL_DEBUG > 1 if(*error_p) RASQAL_DEBUG1("rasqal_literal_equals_flags() returned: FAILURE\n"); else RASQAL_DEBUG2("rasqal_literal_equals_flags() returned: %d\n", found); #endif rasqal_free_literal(arg_literal); if(*error_p) goto failed; if(found) /* found - terminate search */ break; } rasqal_free_literal(l1); if(e->op == RASQAL_EXPR_NOT_IN) found = !found; return rasqal_new_boolean_literal(world, found); failed: if(error_p) *error_p = 1; if(l1) rasqal_free_literal(l1); return NULL; }
/* * raptor_turtle_emit_subject_list_items: * @serializer: #raptor_serializer object * @subject: subject node * @depth: depth into tree * * Emit an rdf list of items (rdf:li) about a subject node. * * Return value: non-0 on failure **/ static int raptor_turtle_emit_subject_list_items(raptor_serializer* serializer, raptor_abbrev_subject* subject, int depth) { int rv = 0; int i=0; RAPTOR_DEBUG5("Emitting subject list items for node %p refcount %d subject %d object %d\n", subject->node, subject->node->ref_count, subject->node->count_as_subject, subject->node->count_as_object); while(!rv && i < raptor_sequence_size(subject->list_items)) { raptor_abbrev_node* object; object = (raptor_abbrev_node*)raptor_sequence_get_at(subject->list_items, i++); if(!object) continue; switch(object->type) { case RAPTOR_IDENTIFIER_TYPE_RESOURCE: rv = raptor_turtle_emit_resource(serializer, object, depth+1); break; case RAPTOR_IDENTIFIER_TYPE_LITERAL: rv = raptor_turtle_emit_literal(serializer, object, depth+1); break; case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: rv = raptor_turtle_emit_xml_literal(serializer, object, depth+1); break; case RAPTOR_IDENTIFIER_TYPE_ANONYMOUS: rv = raptor_turtle_emit_blank(serializer, object, depth+1); break; case RAPTOR_IDENTIFIER_TYPE_ORDINAL: /* ordinals should never appear as an object with current parsers */ case RAPTOR_IDENTIFIER_TYPE_PREDICATE: /* predicates should never appear as an object */ case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: default: RAPTOR_FATAL1("Unsupported identifier type\n"); break; } } return rv; }
static int raptor_avltree_print(raptor_avltree* tree, FILE* stream) { if(!tree) return 1; fprintf(stream, "Group sequence with %d groups\n", raptor_sequence_size(tree->seq)); raptor_sequence_print(tree->seq, stream); return 0; }
/** * rasqal_query_results_get_row_from_saved: * @query_results: Query results to execute * * INTERNAL - Get next result row from a stored query result sequence * * Return value: result row or NULL if finished or failed */ static rasqal_row* rasqal_query_results_get_row_from_saved(rasqal_query_results* query_results) { rasqal_query* query = query_results->query; int size; rasqal_row* row = NULL; size = raptor_sequence_size(query_results->results_sequence); while(1) { int check; if(query_results->result_count >= size) { query_results->finished = 1; break; } query_results->result_count++; check = rasqal_query_check_limit_offset(query, query_results->result_count); /* finished if beyond result range */ if(check > 0) { query_results->finished = 1; query_results->result_count--; break; } /* continue if before start of result range */ if(check < 0) continue; /* else got result */ row = (rasqal_row*)raptor_sequence_get_at(query_results->results_sequence, query_results->result_count - 1); if(row) { row = rasqal_new_row_from_row(row); /* stored results may not be canonicalized yet - do it lazily */ rasqal_row_to_nodes(row); query_results->row = row; if(query && query->constructs) rasqal_query_results_update_bindings(query_results); } break; } return row; }
fs_binding *fs_binding_apply_filters(fs_query *q, int block, fs_binding *b, raptor_sequence *constr) { fs_binding *ret = fs_binding_copy(b); if (!constr) { /* if there's no constriants then we don't need to do anything */ return ret; } for (int col=0; b[col].name; col++) { ret[col].vals->length = 0; } int length = fs_binding_length(b); fs_binding *restore = q->bt; q->bt = b; /* TODO should prefetch lexical vals here */ /* expressions that have been optimised out will be replaces with NULL, * so we have to be careful here */ /* --------------------------- */ /* PREFETCH should go here XXX */ /* --------------------------- */ for (int row=0; row<length; row++) { for (int c=0; c<raptor_sequence_size(constr); c++) { rasqal_expression *e = raptor_sequence_get_at(constr, c); if (!e) continue; fs_value v = fs_expression_eval(q, row, block, e); #ifdef DEBUG_FILTER rasqal_expression_print(e, stdout); printf(" -> "); fs_value_print(v); printf("\n"); #endif if (v.valid & fs_valid_bit(FS_V_TYPE_ERROR) && v.lex) { q->warnings = g_slist_prepend(q->warnings, v.lex); } fs_value result = fn_ebv(v); /* its EBV is not true, so we skip to the next one */ if (result.valid & fs_valid_bit(FS_V_TYPE_ERROR) || !result.in) { continue; } for (int col=0; b[col].name; col++) { if (b[col].bound) { fs_rid_vector_append(ret[col].vals, b[col].vals->data[row]); } } } } q->bt = restore; return ret; }
static int manifest_testsuite_result_format(FILE* fh, manifest_test_result* result, const char* ts_name, unsigned indent, int verbose) { raptor_sequence* seq; int i; seq = result->states[STATE_FAIL]; if(seq && raptor_sequence_size(seq)) { manifest_test* t; manifest_indent(fh, indent); fputs("Failed tests:\n", fh); for(i = 0; (t = RASQAL_GOOD_CAST(manifest_test*, raptor_sequence_get_at(seq, i))); i++) { manifest_indent(fh, indent + indent_step); if(verbose) { manifest_banner(fh, banner_width, '='); manifest_indent(fh, indent + indent_step); fprintf(fh, "%s in suite %s\n", t->name, ts_name); } else { fputs(t->name, fh); fputc('\n', fh); } if(verbose && t->result->details) { manifest_indent(fh, indent + indent_step); fputs(t->result->details, fh); fputc('\n', fh); } if(verbose && t->result->log) { manifest_indent_multiline(fh, t->result->log, indent + indent_step * 2, 15); } if(verbose) { manifest_indent(fh, indent + indent_step); manifest_banner(fh, banner_width, '='); } } }
/** * rasqal_rowsource_print_row_sequence: * @rowsource: rowsource associated with rows * @seq: query result sequence of #rasqal_row * @fp: FILE* handle to print to * * INTERNAL - Print a result set header with row values from a sequence */ void rasqal_rowsource_print_row_sequence(rasqal_rowsource* rowsource, raptor_sequence* seq, FILE* fh) { int size = raptor_sequence_size(seq); int i; rasqal_rowsource_print_header(rowsource, fh); for(i = 0; i < size; i++) { rasqal_row *row = (rasqal_row*)raptor_sequence_get_at(seq, i); rasqal_row_print(row, fh); fputs("\n", fh); } }
static int rasqal_query_write_sparql_select(sparql_writer_context *wc, raptor_iostream *iostr, raptor_sequence* vars_seq) { int count = raptor_sequence_size(vars_seq); int i; for(i = 0; i < count; i++) { rasqal_variable* v = (rasqal_variable*)raptor_sequence_get_at(vars_seq, i); raptor_iostream_write_byte(' ', iostr); rasqal_query_write_sparql_variable(wc, iostr, v); } return 0; }
/* * raptor_turtle_emit_subject_list_items: * @serializer: #raptor_serializer object * @subject: subject node * @depth: depth into tree * * Emit an rdf list of items (rdf:li) about a subject node. * * Return value: non-0 on failure **/ static int raptor_turtle_emit_subject_list_items(raptor_serializer* serializer, raptor_abbrev_subject* subject, int depth) { int rv = 0; int i = 0; RAPTOR_DEBUG5("Emitting subject list items for node %p refcount %d subject %d object %d\n", subject->node, subject->node->ref_count, subject->node->count_as_subject, subject->node->count_as_object); while(!rv && i < raptor_sequence_size(subject->list_items)) { raptor_abbrev_node* object; object = (raptor_abbrev_node*)raptor_sequence_get_at(subject->list_items, i++); if(!object) continue; switch(object->term->type) { case RAPTOR_TERM_TYPE_URI: rv = raptor_turtle_emit_resource(serializer, object, depth+1); break; case RAPTOR_TERM_TYPE_LITERAL: rv = raptor_turtle_emit_literal(serializer, object, depth+1); break; case RAPTOR_TERM_TYPE_BLANK: rv = raptor_turtle_emit_blank(serializer, object, depth+1); break; case RAPTOR_TERM_TYPE_UNKNOWN: default: raptor_log_error_formatted(serializer->world, RAPTOR_LOG_LEVEL_ERROR, NULL, "Triple has unsupported term type %d", object->term->type); break; } } return rv; }
/* Check the list to see if the node is a duplicate. If not, add it * to the list. */ static void raptor_dot_serializer_assert_node(raptor_serializer* serializer, raptor_identifier_type node_type, const void* node_data, raptor_uri* datatype, const unsigned char* language) { raptor_dot_context* context = (raptor_dot_context*)serializer->context; raptor_sequence* seq = NULL; int i; /* Which list are we searching? */ switch(node_type) { case RAPTOR_IDENTIFIER_TYPE_RESOURCE: case RAPTOR_IDENTIFIER_TYPE_PREDICATE: seq = context->resources; break; case RAPTOR_IDENTIFIER_TYPE_ANONYMOUS: seq = context->bnodes; break; case RAPTOR_IDENTIFIER_TYPE_LITERAL: case RAPTOR_IDENTIFIER_TYPE_XML_LITERAL: seq = context->literals; break; case RAPTOR_IDENTIFIER_TYPE_UNKNOWN: case RAPTOR_IDENTIFIER_TYPE_ORDINAL: break; } for( i = 0 ; i < raptor_sequence_size(seq) ; i++ ) { raptor_dot_serializer_node* node = (raptor_dot_serializer_node*)raptor_sequence_get_at(seq, i); if(raptor_dot_serializer_node_matches(node, node_type, node_data, datatype, language) ) return; } raptor_sequence_push(seq, raptor_dot_serializer_new_node(node_type, node_data, datatype, language)); }
static rasqal_row* rasqal_rowsource_sparql_xml_read_row(rasqal_rowsource* rowsource, void *user_data) { rasqal_rowsource_sparql_xml_context* con; rasqal_row* row=NULL; con=(rasqal_rowsource_sparql_xml_context*)user_data; rasqal_rowsource_sparql_xml_process(con); if(!con->failed && raptor_sequence_size(con->results_sequence) > 0) { RASQAL_DEBUG1("getting row from stored sequence\n"); row=(rasqal_row*)raptor_sequence_unshift(con->results_sequence); } return row; }
static void* raptor_avltree_search(raptor_avltree* tree, const void* p_data) { int size; int i; if(!tree) return NULL; size = raptor_sequence_size(tree->seq); for(i = 0; i < size; i++) { void* data = raptor_sequence_get_at(tree->seq, i); if(!tree->compare_handler(p_data, data)) return data; } return NULL; }
/** * rasqal_query_results_add_row: * @query_results: query results object * @row: query result row * * Add a query result row to the sequence of result rows * * Return value: non-0 on failure */ int rasqal_query_results_add_row(rasqal_query_results* query_results, rasqal_row* row) { RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(query_results, rasqal_query_results, 1); RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(row, rasqal_row, 1); if(!query_results->results_sequence) { query_results->results_sequence = raptor_new_sequence((raptor_data_free_handler)rasqal_free_row, (raptor_data_print_handler)rasqal_row_print); if(!query_results->results_sequence) return 1; query_results->result_count = 0; } row->offset = raptor_sequence_size(query_results->results_sequence); return raptor_sequence_push(query_results->results_sequence, row); }
/** * rasqal_query_results_next_triple: * @query_results: #rasqal_query_results query_results * * Move to the next triple result. * * Return value: non-0 if failed or results exhausted **/ int rasqal_query_results_next_triple(rasqal_query_results* query_results) { rasqal_query* query; int rc = 0; RASQAL_ASSERT_OBJECT_POINTER_RETURN_VALUE(query_results, rasqal_query_results, 1); if(query_results->failed || query_results->finished) return 1; if(!rasqal_query_results_is_graph(query_results)) return 1; query = query_results->query; if(!query) return 1; if(query->verb == RASQAL_QUERY_VERB_DESCRIBE) return 1; if(query_results->triple) { rasqal_free_triple(query_results->triple); query_results->triple = NULL; } if(++query_results->current_triple_result >= raptor_sequence_size(query->constructs)) { /* Remove any current row */ if(query_results->row) { rasqal_free_row(query_results->row); query_results->row = NULL; } /* Now try to get a new one */ if(rasqal_query_results_ensure_have_row_internal(query_results)) return 1; query_results->current_triple_result = -1; } return rc; }