[redland-dev] How do you convert a Redland statement to a Redland stream?
Lou Sakey
ljsakey at verizon.net
Mon Sep 8 23:15:23 CEST 2008
While looking at Sparql performance I noticed that some of the calls from
the Rascal library to librdf_storage_find_statements() contained a statement
with all three nodes completely specified.
As currently coded having all three nodes defined prevents the use of the
efficient storage back end methods (find_sources(), find_arcs(), and
find_targets()) when configured with a hashed storage module like the
Berkeley DB.
I would like to change this behavior.
To handle the case where a complete statement is passed into
librdf_storage_find_statements(), I wanted to add the following:
1. Call find_targets() with the subject and predicate nodes from the
passed in statement.
2. Use the iterator returned from find_targets() to iterate over the
target nodes checking for the object node that matches the object node from
the passed in statement.
3. If the object node does not exists, return an empty stream by
calling librdf_new_empty_stream().
4. If the object node does exists, create a stream from the statement.
Step 4 is where I am stuck. The iterator from step one can't be used in the
call to librdf_new_stream_from_node_iterator() because it may contain more
than the desired object node.
In the example below this could be caused by multiple "lou:hobby"
properties.
Here is a copy of the query.
PREFIX lou: <http://ns.lou.com/2007/lou-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT * WHERE {
?subject lou:Sex 'male'.
?subject lou:hobby 'camping'.
?subject lou:BirthDate ?p1.
FILTER (
( (xsd:dateTime(?p1) <=
xsd:dateTime('2008-01-31T00:00:00')) && (xsd:dateTime(?p1) >=
xsd:dateTime('2008-01-01T00:00:00')) )
) }
It is expected to find all males born in January of 2008 that have a camping
hobby.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.librdf.org/pipermail/redland-dev/attachments/20080908/dc196cf4/attachment.htm
More information about the redland-dev
mailing list