[redland] model get_targets question

Dave Beckett dave.beckett at bristol.ac.uk
Sun Dec 3 21:33:32 GMT 2000


>>>Bob Stayton said:
> I'm trying to use the Perl API in Redland, and I've
> got much of it working.  But one feature quite
> confuses me:  $model->get_targets.

<snip/>

> Perl debug shows I'm getting back an Iterator object.

<snip/> 

> What exactly is an iterator, and what does it mean
> that a node is shared with it?  More importantly, how
> can I get my target node back?

Iterator is documented in the general C API used to represent a list
of items as an object usually for returning as the result of a
function.  Since at the user level (rather than internal to Redland)
the only thing that this appears as, I redefined Iterator for
Perl/Python to be a list of librdf_node (Perl RDF::Node) references.

Post Redland 0.9.6 release I changed the get_* methods for Perl so
that they return a perl array when used in an array context rather
than an iterator object.  That makes a lot more sense and is easier
to use in Perl. [ I would do the same with python if I knew more about
its C interface. ]  I probably will add get_target etc. methods that
return an arbitrary target for the given subject, predicate etc.

So now you can do:

  my(@targets)=$model->get_targets($subject, $predicate);

and get a list where each item is an RDF::Node object.

Bob: You did seem to describe an example that did the wrong thing -
returning a list of badly constructed objects, can you mail it to me
so I can try it out?

> 
> BTW, do you need some help documenting the Perl API?

That sounds like a hint, as well as an offer!  Thanks.

What I wanted to do was integrate the autogenerated Javadoc-style C
API information with perl documentation into perl POD files, but only
once I was happy that the Perl interface was pretty stable.  I am
getting more happy with that since I've used it for enough code now
that it seems natural, so I guess some Perl docs describing the
differences would be a good idea!

I guess I should release 0.9.7 despite there being few large changes
so people are up to date.  I intend in the medium term to have a
public read-only cvs so you can get the latest stuff.  Until then,
the LXR web space will have to do.

Dave







More information about the redland-dev mailing list