njh / redstore

RedStore is a lightweight RDF triplestore written in C using the Redland library.
https://www.aelius.com/njh/redstore/
GNU General Public License v3.0
62 stars 6 forks source link

Redstore, in-memory hashes storage, and ASK queries #46

Closed moustaki closed 12 years ago

moustaki commented 12 years ago

To reproduce spawn a new redstore instance with default in-memory storage. Insert a single triple . Run the query ASK . Redstore returns false.

This doesn't happen with the sqlite storage.

Also, this doesn't happen in redland:

echo "http://ex.com/a http://ex.com/b http://ex.com/c ." > t.ttl rdfproc test parse t.ttl turtle rdfproc test query sparql - "ASK { http://ex.com/a http://ex.com/b http://ex.com/c }"

njh commented 12 years ago

Hello,

Althought it isn't possible to test this properly with rdfproc and in-memory hashes, looks like this is a bug in the Redland 'hashes' storage type because it fails for bdb too.

The ASK query is only failing when querying for a triple in a context / named-graph. If you insert the triple into the default graph, it works on RedStore too.

Works:

echo "<http://ex.com/a> <http://ex.com/b> <http://ex.com/c> ." > test.nt
curl -T test.nt -X POST -H "Content-Type: text/plain" http://localhost:8080/data/?default
curl http://localhost:8080/query?query=ASK+%7B+%3Chttp%3A%2F%2Fex.com%2Fa%3E+%3Chttp%3A%2F%2Fex.com%2Fb%3E+%3Chttp%3A%2F%2Fex.com%2Fc%3E+.+%7D

Fails:

echo "<http://ex.com/a> <http://ex.com/b> <http://ex.com/c> ." > test.nt
curl -T test.ttl -H "Content-Type: text/turtle" http://localhost:8080/data/test.nt
curl -H "Accept: text/plain" http://localhost:8080/data/test.nt
curl http://localhost:8080/query?query=ASK+%7B+%3Chttp%3A%2F%2Fex.com%2Fa%3E+%3Chttp%3A%2F%2Fex.com%2Fb%3E+%3Chttp%3A%2F%2Fex.com%2Fc%3E+.+%7D

Works:

echo "<http://ex.com/a> <http://ex.com/b> <http://ex.com/c> ." > test.nt
rdfproc -n -c test parse test.nt ntriples http://ex.com/
rdfproc -c test serialize ntriples
rdfproc -c test query sparql - "ASK { <http://ex.com/a> <http://ex.com/b> <http://ex.com/c> }"

Fails:

echo "<http://ex.com/a> <http://ex.com/b> <http://ex.com/c> ." > test.nt
rdfproc -n -c test parse test.nt ntriples http://ex.com/ http://ex.com/
rdfproc -c test serialize ntriples
rdfproc -c test query sparql - "ASK { <http://ex.com/a> <http://ex.com/b> <http://ex.com/c> }"

Even more strange, is that it is only complete patterns that are failing:

?s ?p ?o : **true**
<http://ex.com/a> ?p ?o : **true**
<http://ex.com/a> <http://ex.com/b> ?o : **true**
<http://ex.com/a> <http://ex.com/b> <http://ex.com/c> : **false**

I will report a bug in Redland.

njh commented 12 years ago
njh commented 12 years ago

This has now been fixed in librdf: https://github.com/dajobe/librdf/commit/6b6cc2ab356af57bcefc98fef12f350ad01380a8

Test added to RedStore: f336e5cad98cdf0bc8d11b9f7207c0114e2db0e8 (now passing)

moustaki commented 12 years ago

Many thanks Nick!