[redland-dev] Redland contexts vs named graphs

Dave Beckett dave at dajobe.org
Mon Oct 11 18:12:11 CEST 2010


On Sun, 10 Oct 2010, michael wrote:
> Redland does not directly support named graphs. Instead, named graphs can be implemented by clients using Redland's
> context facility. I've been trying to do this and have been running into difficulties.
>
> From the release notes for 0.9.17 [1]:
>
>   * Check that duplicate statements are not added to models with the librdf_model_add_statement and
>     librdf_model_add_statements methods.
>   * The methods for adding statements with a context do not check.
>
> While adding statements to the model without a context will not introduce duplicates, if a model contains any statement
> with a context, duplicates may be returned. So the duplicate restriction to *adding* statements via the
> librdf_model_add_statement(s) methods is misleading because it does not ensure that a model will not *return*
> duplicates. To ensure uniqueness, clients must examine each statement, skipping those with a context set. Sometimes this
> is not even possible for functions like librdf_model_size or any other function that does not accept a context argument.
>
> When querying statements with a particular context, the client again must perform duplicate checking since these
> statements aren't checked for duplicates. However this case is not as simple as the previous one. The client must keep
> track of all previously seen statements to recognize duplicates. If large datasets are queried, this might be
> prohibitive. Doing this for all calls to the library seems like something the library should be providing.
>
> Would it be possible to have an option or another api that limits requests to only statements without a context? Another
> possibility would be to have a special context name to refer to this set. Also, could the context option be added to the
> other functions? The one that's especially important is librdf_model_size. Selecting all statements and counting them in
> the client is not very scalable.
>
> There is an outstanding bug report [2] that addresses this that hasn't seen much activity. Perhaps the severity and
> priority of this bug could be reconsidered?
>
> -Michael
>
> [1] http://librdf.org/RELEASE.html#rel0_9_17
> [2] http://bugs.librdf.org/mantis/view.php?id=108


Having working more recently with the SPARQL world of graphs, default 
graphs and datasets I can now see more clearly that the redland contexts 
feature is insufficient for named graphs as used today  (contexts were 
created quite some time ago).

I would be open to proposals and code for improving this area, and it may 
need both new APIs and some larger changes internally to properly provide 
the sparql dataset (named graphs) semantics required.  Approximately a 
librdf_model should correspond to a sparql dataset.  I am not sure if 
there should be a librdf_graph or librdf_dataset abstraction.

Dave


More information about the redland-dev mailing list