[redland-dev] Re: [patch] librdf_storage_hashes_context_serialise_get_statement

Michael Stahl Michael.Stahl at Sun.com
Wed May 7 12:50:05 BST 2008


John Fieber wrote:
> On May 6, 2008, at 5:23 AM, Michael Stahl wrote:
> =

>> so i found another problem in librdf_stream_get_context... namely that =

>> it does not work with hashes storage.
> =

> Do you have a simple test case to illustrate this?  I'm able to retrieve =

> contexts in streams on hashes storage without trouble.

attached.
its output:
object: 298c8   context: 0

> That said, I do have a different problem with iterator/stream map =

> functions regarding contexts.  The mapping function for an iterator has =

> the signature (rdf_iterator.h):
> =

>   typedef void* (*librdf_iterator_map_handler)(librdf_iterator =

> *iterator, void *map_context, void *item);
> =

> The problem is the list of iterator methods you cannot call within the =

> map function because they produce infinite recursion:
> =

>  librdf_iterator_have_elements
>  librdf_iterator_end
>  librdf_iterator_next
>  librdf_iterator_get_object
>  librdf_iterator_get_context
>  librdf_iterator_get_key
>  librdf_iterator_get_value
> =

> Clearly not all of those are necessary or even appropriate to use in a =

> map callback since you are handed a pointer to the object, but getting =

> the context is relevant, and the only way to get it is to violate =

> encapsulation of the iterator.  The stream methods exhibit the same =

> behavior.

uhm, it is not legal to call librdf_stream_get_context in a stream map =

function?
i am doing this right now, and it seemed to work so far...
(of course, i would never expect _next to work)
but clearly it needs to be documented somewhere which ones supposedly work =
:)

> Another bug that affects the iterator only is that the callback =

> signature is
> =

>   typedef void* (*librdf_iterator_map_handler)(librdf_iterator =

> *iterator, void *map_context, void *item);
> =

> but it called with second two arguments swapped (rdf_iterator.c):
> =

>       /* apply the map to the element  */
>       element=3Dmap->fn(iterator, element, map->context);
> =

> I'm guessing this is wrong since the argument order is consistent in =

> three out of four cases: stream callback signature, stream callback call =

> and iterator callback signature.
> =

> -john

ah, the famous type safety of C (or lack thereof)...

-- =

"A supercomputer is a device for converting a CPU-bound problem into
  an I/O bound problem." -- Ken Batcher
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashes_context.c
Type: text/x-csrc
Size: 1379 bytes
Desc: not available
Url : http://lists.usefulinc.com/pipermail/redland-dev/attachments/20080507=
/b1ddc6e3/hashes_context.c


More information about the redland-dev mailing list