[redland] Way to get iterator of unique (distinct) sources?

Dave Beckett Dave.Beckett at bristol.ac.uk
Tue Nov 19 20:52:41 GMT 2002


>>>Seth Ladd said:
> Hello,
> 
> Is there a way to say "Give me a list of all distinct Subjects in this 
> model"?  I've tried librdf_model_get_sources(model, NULL, NULL) but that 
> seems to be returning an empty iterator (even though I know there are 
> statements in the model).

The get_sources method on model isn't a search; the two arguments
must both be present.  As such the above won't work at all and will
always return nothing.

As to the question of getting all *distinct* subjects of a graph; ie
the resources, there is no method call yet that will do it.  I have
considered adding it to the API, still might.

However, to efficiently do this from a general set of triples, I was
considering adding later as an option to the iterators/streams.  They
can take filtering/mapping operations on the streams of items so it
would make sense to do this by using such a callback function with a
hash keyed off the item.  (At the C level, an in-memory librdf_hash
could be used).

Or it could be done at the higher level language layer such as by
using perl hashes or python, java, etc. equivalents

Dave








More information about the redland-dev mailing list