You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Torrance Slauson <to...@yahoo.com> on 2012/02/02 18:20:24 UTC

Graph Layer question

I've been working with Jena for a while, but limited mainly to the model layer. Within the past week, I've been trying to take my knowledge of the API to a deeper level. I'm interested in the idea of being able to use named graphs (perhaps as provenance for a given data source), and learning about Quads as well.

I've been spending time on the Graph layer, and have a question given the code below (ARQ 2.8.8, Jena 2.6.4, TDB 0.8.10):

  DatasetGraph dsg = TDBFactory.createDatasetGraph(“/path/”);
  Node gn = Node.createURI(namespace.concat("itp.graph"));
  Graph g = dsg.getGraph(gn);

  Node s = Node.createURI(namespace.concat("joe"));
  Node p = Node.createURI(namespace.concat("seenAt"));
  Node o = Node.createURI(namespace.concat("wendys"));

  Triple t = new Triple(s, p, o);
  g.add(t);
 
  dsg.addGraph(gn, g);
  System.out.println(dsg);

The last line prints out what I expect to see:
(dataset
  (graph)
    (graph <http://mynamespace.com#itp.graph>
      (triple <http://mynamespace.com#joe> <http://mynamespace.com#seenAt> <http://mynamespace.com#wendys>)
    ))

If I use this code on a subsequent call:
  DatasetGraph dsg = TDBFactory.createDatasetGraph(“/path/”);
  System.out.println(dsg);

I get nothing:
  (dataset
    (graph)
  )

The triple I created in the first call doesn't appear to be persisted. Is that expected behavior at the graph layer (which I understand has pretty minimal functionality), or have I missed something? I was wondering if someone could shed more light on this. Thanks!

Re: Graph Layer question

Posted by Damian Steer <d....@bristol.ac.uk>.
On 2 Feb 2012, at 17:20, Torrance Slauson wrote:

>   DatasetGraph dsg = TDBFactory.createDatasetGraph(“/path/”);

>   dsg.addGraph(gn, g);
>   System.out.println(dsg);

You don't seem to have closed your DatasetGraph, which might explain what you're seeing.

Damian