On 25/06/13 22:54, Cindy A McMullen wrote:
Let's make things even simpler:  How do I load a set of Quads into SDB via the 
Java API (not 'sdbloader')?


On Jun 25, 2013, at 11:32 AM, Cindy A McMullen wrote:

I want to load triples into an empty SDB Store.  Here's what I'm trying:

Store store = getStore();
GraphSDB graph = new GraphSDB(store);
DatasetGraph datasetGraph = DatasetGraphFactory.create(graph);

This will not do what you want.

It puts a single SDB-backed graph inside a general purpose, in-memory DatasetGraph. It's for use when you are mixing graphs from different places.

You seem to be using the previous release of SDB - the current release, with current Jena, will silently create new graphs BUT in-memory. In the last version of SDB you had to explicitly create graphs in the general dataset so it knew which storage layer to use.

You want the whole dataset to be SDB-backed:

    Dataset ds = SDBFactory.connectDataset(...) ;
    DatasetGraph dsg = ds.asDatasetGraph() ;
    dsg.add(quad) ;


if (datasetGraph.isEmpty())
{
      System.out.println("Empty dataset graph");      // yes, it is
}
for (EventGraph eventGraph : eventGraphs)   // internal classes
{
         persist(eventGraph, datasetGraph);   // code below
}

--------
I'm calling into the same code that I use for in-memory implementation to 
persist:

protected void persist(EventGraph eventGraph, DatasetGraph dsg)
    {
        // First,  pull the triples from the Set<Event>.
        Set<Triple> triples = generateTriplesFromGraphEvent(eventGraph);

        // Named graph node, into which we'll store the event triples
        Node graphNode = Node.createURI(UUID.randomUUID().toString());

This is not a URI.

Either
        "urn:uuid:"+UUID.randomUUID().toString()
or
        JenaUUID.generate().asURN() ;


        // Next, create a Jena Quad for that
        for (Triple triple : triples)
        {
            Quad q = new Quad(graphNode, triple);
            dsg.add(q);
        }

        dsg.add(new Quad(Quad.defaultGraphIRI, createActionTriple(graphNode, 
eventGraph)));
        dsg.add(new Quad(Quad.defaultGraphIRI, createTimestampTriple(graphNode, 
eventGraph)));
    }

-------
And get this message for the "dsg.add(q)" line:

Exception in thread "main" com.hp.hpl.jena.shared.JenaException: No such graph: 
ef3f02ef-c203-42af-9e3d-9061acf27022
    DatasetGraphCollection.add(DatasetGraphCollection.java:41)
    InMemoryRDFManager.persist(InMemoryRDFManager.java:98)
    SDBRDFManager.persist(SDBRDFManager.java:58)

----

Any ideas?




Reply via email to