Re: Issue adding Triples to Graph which has been added to a DatasetGraph.

2012-11-30 Thread Dick Murray
Hi Andy.

Thanks for the reply and just so I am sure I understand this... :-)

Looking at the Jena code for a SPARUL create graph urn:test against a
folder backed TDB store it gives the following stack;

Daemon Thread [Thread-24] (Suspended)
GraphMem(GraphMemBase).init(ReificationStyle) line: 52
GraphMem.init(ReificationStyle) line: 35
Factory.createGraphMem(ReificationStyle) line: 50
Factory.createDefaultGraph(ReificationStyle) line: 44
Factory.createDefaultGraph() line: 38
GraphFactory.createJenaDefaultGraph() line: 54
GraphFactory.createDefaultGraph() line: 48

U4DefaultGraph$U4UpdateEngineWorker(UpdateEngineWorker).visit(UpdateCreate)
line: 140
U4DefaultGraph$U4UpdateEngineWorker.visit(UpdateCreate) line: 369
UpdateCreate.visit(UpdateVisitor) line: 58
U4DefaultGraph$U4UpdateEngine.execute() line: 314
UpdateProcessorBase.execute() line: 56
U4DefaultGraph.graphSPARUL(U4HTTPDoRequestMessage) line: 1065
U4DefaultGraph$5.go(Object) line: 857
U4DefaultGraph$3.go(Object) line: 737
U4DefaultGraph(U4DefaultNode).nodeMessageHandler(U4Message) line:
713
U4DefaultNode$MessageHandler.run() line: 625
ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1110
ThreadPoolExecutor$Worker.run() line: 603
Thread.run() line: 722

Specifically GraphFactory.createDefaultGraph() line: 48 is;

/**
Answer a memory-based Graph with the Standard reification style.
*/
public static Graph createDefaultGraph()
{ return createDefaultGraph( ReificationStyle.Standard ); }

So Jena uses a memory based graph to fulfil the create graph request.

But uses add(Quad) to fulfil the insert data [into {iri}] {...} request as
detailed with the following stack.

DatasetGraphTxn(DatasetGraphTriplesQuads).add(Quad) line: 33
DatasetGraphTransaction(DatasetGraphTrackActive).add(Quad) line: 133
GraphStoreBasic(DatasetGraphWrapper).add(Quad) line: 72
UpdateEngineWorker.addToGraphStore(GraphStore, Quad) line: 484
U4DefaultGraph$U4UpdateEngineWorker(UpdateEngineWorker).visit(UpdateDataInsert)
line: 281

So I need to add the graph (as a empty mem based graph) to the TDB backed
dataset then add quads to the dataset..?

Dick.


On 29 November 2012 21:31, Andy Seaborne a...@apache.org wrote:

 On 29/11/12 21:24, Andy Seaborne wrote:

   final Dataset d = TDBFactory.createDataset();
   Node n = Node.createURI(urn:graph);
   d.addGraph(n, GraphFactory.**createDefaultGraph());

 (sorry for the delay replying)

 I'm afraid that isn't going to work.  I suspect it should be an error.


 It seems that the code adds in the contents of the graph into the dataset
 by copying over the triples - i.e. update before adding.

 Andy



 A TDB dataset is a triples+quad store.  You can't add an in-memory
 storage-backed graph to a dataset backed by TDB.

 If you want a mixe dataset, you can create an in-memory dataset and add
 in TDB backed graphs.

  Andy

 On 28/11/12 20:32, Dick Murray wrote:

 Hi all.

 I have an issue where triples which are added to a graph which has been
 added to a dataset are not visible in the dataset.

 However if I add the graph then add quads to the dataset with the quad
 graph node as the node used to add the graph the quads are visible.

 Is this expected?





Re: Issue adding Triples to Graph which has been added to a DatasetGraph.

2012-11-30 Thread Andy Seaborne

On 30/11/12 11:34, Dick Murray wrote:

Hi Andy.

Thanks for the reply and just so I am sure I understand this... :-)


...

So I need to add the graph (as a empty mem based graph) to the TDB backed
dataset then add quads to the dataset..?

Dick.



In TDB graph just are - you don't need to create them explicitly, just 
start adding quads.


A TDB-backed graph, if you get it from the dataset, is just a view of 
the database and has no separate state.


You can get it (no need to create) add triples (or as a model, 
statements) and they become quads view the view.


(You don't need CREATE GRAPH in SPARQL Update either - in fact, you 
don't need it anywhere any more IIRC)


Andy