I've noticed a couple of differences between DatasetFactory.create() and
DatasetFactory.createGeneral().
My understanding is that the former is intended to create deep copies of its
graphs whereas the latter maintains shallow links.
The DatasetFactory has quite a few creational methods, and their documentation
tends to be brief; but a couple of behaviors stood out to me.
1. In the general dataset, containsNamedModel() always returns false for
the default graph.
This seems unexpected whether from the perspective of copies or links.
2. In the general dataset, addNamedModel() appears to perform the same
function as replaceNamedModel().
This is understandable for simplicity; but from the memory dataset
perspective, a combined view of identically-named graphs would be expected.
~ Fun with words: can we say that "identically-named graphs" are
homonymous? ;) ~
Following is some code demonstrating the two points above. Are these behaviors
intentional?
public static void main(String... args) {
Model m1 = ModelFactory.createDefaultModel();
m1.add(m1.createResource(), m1.createProperty("foo"),
m1.createResource());
Model m2 = ModelFactory.createDefaultModel();
m2.add(m2.createResource(), m2.createProperty("bar"),
m2.createResource());
Dataset memory = DatasetFactory.create();
Dataset general = DatasetFactory.createGeneral();
memory.getDefaultModel().add(m1);
general.getDefaultModel().add(m1);
memory.addNamedModel("bar", m2);
general.addNamedModel("bar", m2);
//Memory model contains default graph. General model does not.
System.out.println(memory.containsNamedModel(Quad.defaultGraphIRI.getURI()));
//true
System.out.println(general.containsNamedModel(Quad.defaultGraphIRI.getURI()));
//false
memory.addNamedModel("bar", ModelFactory.createDefaultModel());
general.addNamedModel("bar", ModelFactory.createDefaultModel());
//Memory model add == merge. General model add == replace.
System.out.println(memory.getNamedModel("bar")); //merge
System.out.println(general.getNamedModel("bar")); //replace
}