/* * rasqal_rowsource_remove_all_variables: * @rowsource: rasqal rowsource * * INTERNAL - Remove all variables from a rowsource */ void rasqal_rowsource_remove_all_variables(rasqal_rowsource *rowsource) { while(1) { rasqal_variable* v; v = (rasqal_variable*)raptor_sequence_pop(rowsource->variables_sequence); if(!v) break; rasqal_free_variable(v); } rowsource->size = 0; }
static void navigator_graph_pattern_load(rasqal_graph_pattern *gp, int gp_index,int indent, GSList** template_query_) { int triple_index = 0; raptor_sequence *seq; rasqal_variable * var; rasqal_triple* t; rasqal_literal_type type; GSList* template_query= *template_query_; indent += 1; /* look for triples */ while(1) { t = rasqal_graph_pattern_get_triple(gp, triple_index); if(!t) break; /* rasqal_literal_type type; printf ("triple\n"); type=rasqal_literal_get_rdf_term_type(t->subject); printf ("S type %d val %s\n", type, rasqal_literal_as_string (t->subject)) ; type=rasqal_literal_get_rdf_term_type(t->predicate); printf ("P type %d val %s\n", type, rasqal_literal_as_string (t->predicate)) ; type=rasqal_literal_get_rdf_term_type(t->object); printf ("O type %d val %s\n", type, rasqal_literal_as_string (t->object)) ; */ //ssTriple_t *ttemp = (ssTriple_t *)g_new0(ssTriple_t,1); ssTriple_t_sparql *ttemp = (ssTriple_t_sparql *)g_new0(ssTriple_t_sparql,1); type=rasqal_literal_get_rdf_term_type(t->subject); //var=rasqal_literal_as_variable(t->subject); //rasqal_variable_print(var, stdout); //printf("\n"); //printf("%s\n", var->name); //rasqal_free_variable (var); if ((type==RASQAL_LITERAL_UNKNOWN) && (rasqal_literal_as_string(t->subject) == NULL)) { //variable , needs a wildcard var=rasqal_literal_as_variable(t->subject); ttemp->subject_var=g_strdup(var->name); rasqal_free_variable (var); ttemp->subject=g_strdup_printf("%s",wildcard1); } else { ttemp->subject=g_strdup(rasqal_literal_as_string (t->subject)); ttemp->subject_var=NULL; } type=rasqal_literal_get_rdf_term_type(t->predicate); if ((type==RASQAL_LITERAL_UNKNOWN) && (rasqal_literal_as_string(t->predicate) == NULL)) { //variable , needs a wildcard var=rasqal_literal_as_variable(t->predicate); ttemp->predicate_var=g_strdup(var->name); rasqal_free_variable (var); ttemp->predicate=g_strdup_printf("%s",wildcard1); } else { ttemp->predicate=g_strdup(rasqal_literal_as_string (t->predicate)); ttemp->predicate_var=NULL; } type=rasqal_literal_get_rdf_term_type(t->object); if ((type==RASQAL_LITERAL_UNKNOWN) && (rasqal_literal_as_string(t->object) == NULL)) { //variable , needs a wildcard var=rasqal_literal_as_variable(t->object); ttemp->object_var=g_strdup(var->name); rasqal_free_variable (var); ttemp->object=g_strdup_printf("%s",wildcard1); } else { if (type==RASQAL_LITERAL_STRING) { ttemp->object=g_strdup(rasqal_literal_as_string (t->object)); ttemp->objType = ssElement_TYPE_LIT; } else { ttemp->object=g_strdup(rasqal_literal_as_string (t->object)); ttemp->objType = ssElement_TYPE_URI; } ttemp->object_var=NULL; } ttemp->gp_index=gp_index; ttemp->indent=indent; //printf("SPARQL Binding triple is: \t%s\t%s\t%s , obj_Type %d \n", ttemp->subject, ttemp->predicate, ttemp->object, ttemp->objType); //printf(" Vars: \t%s\t%s\t%s , gp_index %d indent %d\n", ttemp->subject_var, ttemp->predicate_var, ttemp->object_var,ttemp->gp_index,ttemp->indent); template_query= g_slist_prepend(template_query, ttemp); triple_index++; } /* look for sub-graph patterns */ seq = rasqal_graph_pattern_get_sub_graph_pattern_sequence(gp); if(seq && raptor_sequence_size(seq) > 0) { gp_index = 0; while(1) { rasqal_graph_pattern* sgp; sgp = rasqal_graph_pattern_get_sub_graph_pattern(gp, gp_index); if(!sgp) break; navigator_graph_pattern_load(sgp, gp_index, indent + 1, &template_query); gp_index++; } } indent -= 1; *template_query_=template_query; }