On 20/03/12 20:51, Milorad Tosic wrote:
Comment is inserted:

________________________________
From: Dave Reynolds<[email protected]>
To: Milorad Tosic<[email protected]>
Sent: Tuesday, March 20, 2012 2:51 PM
Subject: Re: is GraphStore deepcopy or a facade?

Hi,

On 20/03/12 13:27, Milorad Tosic wrote:
Hi,

Please keep the conversation on jena-dev so others can join in.

But ...

Here is the code segment:


/**
* Select triples in the NamedGraph in the store
*/
querystr = "SELECT * WHERE {GRAPH<http://example.com/graphs/test1/>  {
?s ?p ?o . }}";

So that query is requesting a specific named graph.


Yes.


System.out.println("Running "+querystr);

Query query = QueryFactory.create(querystr);
m_triplestore = ModelFactory.createInfModel(
ReasonerRegistry.getOWLMicroReasoner(),
m_dataset.getNamedModel("urn:x-arq:UnionGraph"));
query.setPrefixMapping(m_triplestore);

m_triplestore.getLock().enterCriticalSection(Lock.READ) ;
try {
QueryExecution qexec = QueryExecutionFactory.create(query, m_triplestore) ;
ResultSet results = qexec.execSelect() ;

But here you are querying a simple model so there is no named graph
there so the result will be empty.


The result shouldn't be empty since I am trying to get named model 
"urn:x-arq:UnionGraph"!

Yes it should. When you query the Model you are querying one graph and it has no name. Think of it like a dataset with just a default graph. The fact that the triples in that model originated by aggregating them from some set of graphs in some dataset makes no difference.

The trick is that exactly the same configuration works without Model in between?

Yes. Querying one model is fundamentally different from querying a Dataset. A model by definition is just one graph of data, no names.

What I am trying to do is to apply some of the existing Jena models on a set of 
named graphs within the same TDB dataset.

Don't follow what you mean by "apply" here.

If you want to reason over the data in the Dataset then as I've already said you can only reason over a single graph/Model, a single collection of triples. The UnionGraph gives you that. The result is just a bigger single bunch of triples, still no graph names so query it as such. If you want to put the inferred triples back into the Dataset as some new named graph then use getNamedModel() and add() the inferred data into it.

I first tried to apply a Model on a integrated set of unnamed (default) graph 
(set of triples) and one named graph (set of quads) residing within the same 
dataset. However, it didn't work. Now, I want to try to apply Model on the 
UnionGraph (that is supposed to contain all named graphs).

No the UnionGraph is a single graph that contains all the triples from all the named graphs. That is not the same as containing the graphs themselves along with their names.

Dave

Reply via email to