[redland-dev] Posing queries to Virtuoso

lorena lorenae at fing.edu.uy
Sat Mar 31 17:25:16 EDT 2012


Hi!
I'm using librdf with Virtuoso. It seems that I have successfully built
everything but I would like to pose queries directly to Virtuoso and this
feature is not working.

According to
http://www.openlinksw.com/dataspace/dav/wiki/Main/VirtRDFDriverRedland in
order to bypass Rasqal 'vsparql' has to be used as the query language.

If I do so, I get no results at all.

Is anybody using this feature?

thanks in advance
Lorena

ps: I´m including a small working example based on Redland test.php

<?php

$world=librdf_php_get_world();

print "<p>Redland world opened\n</p>";

$options = "dsn='Local Virtuoso',user='dba',password='dba'";
$storage_name = "virtuoso";
$name = "http://example.org/salesInstancesSmall#";


# An existing store
$storage=librdf_new_storage($world, $storage_name, $name, $options);
if(!$storage) die("Failed to create new storage\n");

print "<p>Redland storage created</p>";

$model=librdf_new_model($world,$storage,'');
print "<p>Redland model created</p>";


$query = librdf_new_query($world, 'sparql', null, 'PREFIX
fn:<http://www.w3.org/2005/xpath-functions#> select
distinct(fn:substring-after ( "tatoo", "ta") as ?part) where { ?s ?p
?o}', null);

print "<p>Querying : </p>";
$results=librdf_model_query_execute($model, $query);
$count=1;
while($results && !librdf_query_results_finished($results)) {
 print "<p> result $count: {";
 for ($i=0; $i < librdf_query_results_get_bindings_count($results); $i++)
 {
   $val=librdf_query_results_get_binding_value($results, $i);
   if ($val){
     $nval=librdf_node_to_string($val);
   }
   else
     $nval='(unbound)';
   print "  ".librdf_query_results_get_binding_name($results, $i)."=".$nval;
 }
 print "}</p>";
 librdf_query_results_next($results);
 $count++;
}
if ($results) print "Returned $count results\n";
print "Done\n";
?>

And this is the output produced by the code above:

Redland world opened

Redland storage created

Redland model created

Querying :

result 1: { part="false"^^}
Returned 2 results Done

If I replace "sparql" with "vsparql" I get the following output:


Redland world opened

Redland storage created

Redland model created

Querying :
Done

Thanks
Lorena





On Tue, Mar 20, 2012 at 9:56 PM, lorena <lorenae at fing.edu.uy> wrote:
> As stated here
http://librdf.org/docs/api/redland-storage-module-virtuoso.html
>
> "The Virtuoso Redland RDF Provider is an implementation of the Storage
> API, Model and Query interfaces of the Redland framework for RDF. This
> provider enables the execution of queries via the Redland Rasqal query
> engine or via Virtuoso query engine directly against the Virtuoso
> OpenSource Quad Store."
>
> So I just have to figure out how to skip Rasqal and execute the
> queries directly against Virtuoso.
>
> Any hints would be appreciated
>
> Lorena
>
> On Tue, Mar 20, 2012 at 9:40 PM, lorena <lorenae at fing.edu.uy> wrote:
>> Hi:
>>
>> I'm trying to use librdf to execute SPARQL queries over Virtuoso.
>> But, after getting errors trying to use some functions such as
>> fn:substring (having the fn prefix declared inside the query) I've
>> decided to take a look at Virtuoso's log (after enabling Virtuoso log
>> features using trace_on())
>>
>> To my surprise, although I successfully retrieve results, some of the
>> queries I perform are not logged at all, and other queries are similar
>> to the ones I intend to pose but are not the same.
>> Moreover, I've tested my queries using Virtuoso Conductor web client
>> and they run as expected.
>>
>> So, my questions are the following: is librdf doing some parsing or
>> re-writing on my queries? Is it somehow "loading" the model from
>> Virtuoso and using its own querying capabilities to execute my
>> queries? If so, how can I skip this step in order to force Virtuoso to
>> process the queries?
>>
>> thanks in advance
>> Lorena
>>
>> --
>> Lorena Etcheverry
>
>
>
> --
> Lorena Etcheverry



--
Lorena Etcheverry



-- 
Lorena Etcheverry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.librdf.org/pipermail/redland-dev/attachments/20120331/ff241335/attachment.html>


More information about the redland-dev mailing list