Hi Andy,

thank you very much. I saw the example earlier but missed that it
perfectly matches my needs. *facepalm*

In general the approach works really fine. Yet, TDBGraphAssembler seems
to ignore the transaction framework. All is ok when I use the assembler
at the beginning of the code. But when I used the original datasets
transactional before, I get a TDBTransactionException (see below for
more details)

The call correctly reuses the underlying and already created dataset
graph (what is really great for us) but there seems to be no possibility
to force a transaction start.

Is this intended for some reason?

André

Code that fails:

ds1 = TDBFactory.createDataset(new Location("/var/tmp/namedTest1"));
ds1.begin(ReadWrite.READ);
ds1.end();

build = (Dataset) AssemblerUtils.build("/var/tmp/tdbNew.ttl",
"http://jena.hpl.hp.com/2005/11/Assembler#RDFDataset";);

StackTrace:

...
Caused by: com.hp.hpl.jena.tdb.transaction.TDBTransactionException: Not
in a transaction
        at
com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction.get(DatasetGraphTransaction.java:104)
        at
com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction.get(DatasetGraphTransaction.java:1)
        at
com.hp.hpl.jena.sparql.core.DatasetGraphTrackActive.getDefaultGraph(DatasetGraphTrackActive.java:99)
        at
com.hp.hpl.jena.sparql.core.DatasetImpl.getDefaultModel(DatasetImpl.java:103)
        at
com.hp.hpl.jena.tdb.assembler.TDBGraphAssembler.open(TDBGraphAssembler.java:95)
        at
com.hp.hpl.jena.tdb.assembler.TDBGraphAssembler.open(TDBGraphAssembler.java:1)
        at
com.hp.hpl.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:130)
        ... 39 more

Turtle Definition:

@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .

[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

# A dataset of one TDB-backed graph as the default graph and
# an in-memory graph as a named graph.
<#dataset> rdf:type      ja:RDFDataset ;
        ja:defaultGraph <#graph> ;
        ja:namedGraph
        [ ja:graphName      <http://example.org/name1> ;
        ja:graph          <#graph2> ] ;
.

<#graph>        rdf:type tdb:GraphTDB ;
                tdb:location "/var/tmp/namedTest1" ;
.
<#graph2>       rdf:type tdb:GraphTDB ;
                tdb:location "/var/tmp/namedTest2" ;



On 10.09.2013 12:30, Andy Seaborne wrote:
>> Hello Jena community,
>>
>> I'm looking for a possibility to SPARQL two different TDB backed
>> datasets within one query. The background is that I have a few TDB
>> stores (say A and B) and one special TDB store S containing a few
>> triples that I want to "share" with the other stores.
>> For instance I want to do something like this:
>>
>> SELECT ?o WHERE { GRAPH <S> { ?s ?p ?o. } GRAPH <A> { ?s1 ?p1 ?o.} }
>>
>> In addition, S needs to be writeable and the changes need to be promptly
>> visible for other queries. Even if I change A to B in the above example.
>>
>> I know about named graphs but unfortunately they are no option in our
>> scenario. Could I do it by using assemblers? Or is there any other
>> possibility?
>>
>> We use the current versions of Jena/ARQ/TDB in pure Java.
> 
> You can create a single dataset with graphs from different storages, the
> your queries will look exactly as in your example.
> 
> This can be done in an assembler or in code.
> 
> Example:
> 
> http://jena.apache.org/documentation/tdb/assembler.html#mixed-datasets
> 
>     Andy
> 

-- 
Dr. André Lanka  *  0178 / 134 44 47  *  http://dr-lanka.de

Reply via email to