On 22/11/15 23:16, Gregor Trefs wrote:
Dear Jena Devs,

I am further into my application and think I found a violation of the
Liskov Substitution principle. In short, the principle states that using a
subtype of a type should not alter the meaning of the application. While I
was driving my application, I discovered this fuzzy description of
method org.apache.jena.sparql.core.DatasetGraph.getGraph(Node).

/** Get the graph named by graphNode : returns null on no graph
      * NB Whether a dataset contains a graph if there are no triples is not
defined - see the specifc implementation.
      * Some datasets are "open" - they have all graphs even if no triples,
      * */

You may wish to read the SPARQL Update spec on the subject as well. It has to take account the different needs of different implementations.

While I see the point, that some dataset graphs follow the Open World
Principle and, therefore, rather return an empty graph instead of a
nothing, it is a struggle for me as a developer because I cannot reason
about the actual behaviour when I first call Dataset.remove and then
Dataset.getNamedModel to assure that the model is gone. Using the dataset
which is returned by the TDBFactory would actually fails this test.

Note also that getGraph() could be called and returned before remove - then what?

My questions are: Is there a guideline which Datasetgraphs are used when?

Note the javadoc for removeGraph:

 /** Remove all data associated with the named graph */

"remove all data" means the contract is that there are no triples in the graph.

(Even this isn't possible with inference graphs but let's skip the meaning of axiomatic triples and read "data" as "useful data")

So you can reason about before and after.

Is there a possibility to determine whether a graph is present or not?

Testing whether there is any content is a good plan.

containsGraph(graphName) is best implemented as the
equivalent of find(graphName, ?, ? ?).hasNext()

In DatasetGraphs implemented in Jena itself, that is true (AFAIK). For ones implemented by 3rd parties, you'll have to check with them.

How
does the union of all dataset graphs look like under the "open" assumption?

An RDF Graph is a set of triples.

The union is not affected by empty graphs.

        Andy


Best regards,
Gregor


Reply via email to