On 19/03/12 10:18, Milorad Tosic wrote:
Hi,

I am trying to understand how NamedGraphs work in Jena+TDB and how to use 
SPARQL for the purpose. The API that I found as an eventual candidate that 
would fit the task is GraphStore. My initial understanding was that GraphStore 
is a kind of facade on top of the TDB store that should be used in a case of 
incoming UPDATE query if there is a chance that the query eventually deals with 
NamedGraphs. However, the test gives somewhat unexpected results (suggesting 
that the GraphStore may actually be deep copy of the store?).

What am I missing here? I am afraid that my understanding of the conceptual 
model of NamedGraphs in Jena+TDB is not correct. How should the SPARQL query 
processing be organized in the case of TDB store working with named graphs?


Regards,
Milorad


Hi there,

There is a problem in this line:

             GraphStore graphStore = GraphStoreFactory.create(m_triplestore) ;

which takes a model, without knowing the dataset it comes from, and asks for a GraphStore. A temporary dataset is created which in actually another in-memory dataset unconnected to the original m_dataset.

Datasets are the unit of collections of graphs.

Ideally, try to use datasets everywhere and think of the models as views into the dataset. If you want to work across the model container, work on a dataset.

But, beware, there is second trap waiting for you :-)

TDB does not know about empty graphs - if it has no triples, as far as TDB is concerned, it does not exist. CREATE GRAPH is a no-op for TDB. There is no separate management of graphs, only the triples and quads tables. No entries => does not show up in

SELECT ?g WHERE { GRAPH ?g { } }

(you don't need DISTINCT)

GraphStore is actually just a wrapper around the dataset - it's stateless but it works on datasets.

        Andy

Reply via email to