[redland-dev] How do you convert a Redland statement to a Redland stream?

Lauri Aalto laalto at gmail.com
Tue Sep 9 14:40:01 CEST 2008


Hi,

Have a look at the contains_statement() storage callback
implementation on how to check for existence of a complete statement.
Its efficiency varies from storage to storage. The hashes storage
without context nodes uses the all_statements_hash (spo) for this
which should be rather efficient.

For step 4, perhaps the most straightforward way is to roll up stream
callbacks of your own and pass them to librdf_new_stream(). The get()
callback should return the statement, the next() callback should bump
the stream to finished state. Alternatively, you can add an iterator
map function to filter unwanted statements and only then use
librdf_new_stream_from_node_iterator().

Lauri

On Tue, Sep 9, 2008 at 12:15 AM, Lou Sakey <ljsakey at verizon.net> wrote:
> 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.


More information about the redland-dev mailing list