Hi Andy, On Wednesday, January 16, 2019 4:44 PM, Andy Seaborne [mailto:[email protected]] wrote:
> For my understanding here: > Is there a reason not to have a single TDB2 dataset with several graphs > in it with "union graph" set? I guess the main reason is that I couldn't figure out how to load an RDF file in n-triples into a specific graph in a TDB2 dataset... More comments in-line. > On 16/01/2019 09:25, Svensson, Lars wrote: > > Greetings, > > > > I have several TDB2 datasets that I want to expose as named graphs and as a > joint dataset. > > > My basic idea is to have each TDB2 dataset as its own graph and then a joint > dataset combining all graphs with the default graph being the union of all > named > graphs. My configuration is: > > You won't get the union that way because union is a feature of the > storage. > > A union is formed by > <urn:x-arq:UnionGraph> and API call DatasetGraph.getUnionGraph() work on > any dataset, > > You can use in the query: > > FROM <urn:x-arq:UnionGraph> > > or GRAPH <urn:x-arq:UnionGraph> > > and you can build a general (i.e. ad hoc graph combination) dataset with > a union graph as default graph. > > More below. > > > > > @prefix fuseki: <http://jena.apache.org/fuseki#> . > > @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . > > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . > > @prefix tdb2: <http://jena.hpl.hp.com/2016/tdb#> . > > @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> . > > @prefix : <#> . > > > > <#service1> rdf:type fuseki:Service ; > > fuseki:name "/dnb" ; # http://host:port/dnb > > fuseki:serviceQuery "query" ; # SPARQL query service > > fuseki:serviceReadGraphStore "data" ; # SPARQL Graph store > > protocol > (read only) > > fuseki:dataset <#dnb> ; > > . > > > > <#dnb> a ja:RDFDataset ; > > tdb2:unionDefaultGraph true ; > > No effect. This is a ja:RDFDataset, not tdb2:DatasetTDB2. > tdb2:unionDefaultGraph only applies to tdb2:DatasetTDB2. OK. > ---- Example / works for me: > > PREFIX : <#> > PREFIX fuseki: <http://jena.apache.org/fuseki#> > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> > > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> > PREFIX tdb2: <http://jena.apache.org/2016/tdb#> > PREFIX ja: <http://jena.hpl.hp.com/2005/11/Assembler#> > > <#service_tdb> rdf:type fuseki:Service ; > rdfs:label "Selection of TDB2 graphs" ; > fuseki:name "ds" ; > fuseki:serviceQuery "query" ; > fuseki:serviceQuery "sparql" ; > fuseki:serviceUpdate "update" ; > fuseki:serviceUpload "upload" ; > fuseki:serviceReadWriteGraphStore "data" ; > # A separate read-only graph store endpoint: > fuseki:serviceReadGraphStore "get" ; > fuseki:dataset <#dataset> ; > . > > # Dataset with default graph the union graph from the storage TDB2 and 2 > named graphs. > <#dataset> rdf:type ja:RDFDataset ; > ja:defaultGraph <#graph> ; > ja:namedGraph [ > ja:graphName <https://example/ng1> ; > ja:graph <#graph2> > ]; > ja:namedGraph [ > ja:graphName <https://example/ng2> ; > ja:graph <#graph3> > ]; > . > > ## Graphs out of DB2. > > <#graph> rdf:type tdb2:GraphTDB2 ; > tdb2:graphName "urn:x-arq:UnionGraph" ; > tdb2:location "DB2" ; > . > > <#graph2> rdf:type tdb2:GraphTDB2 ; > tdb2:graphName "https://example/ng1" ; > tdb2:location "DB2" ; > . > <#graph3> rdf:type tdb2:GraphTDB2 ; > tdb2:graphName "https://example/ng" ; > tdb2:location "DB2" ; > . > > > > > ja:namedGraph [ > > ja:graphName <https://d-nb.info/datasets/authorities#dataset> ; > > ja:graph <#authorities> > > ]; > > ja:namedGraph [ > > ja:graphName <https://d-nb.info/datasets/bib#dataset> ; > > ja:graph <#bib> > > ]; > > ja:namedGraph [ > > ja:graphName <https://d-nb.info/datasets/dnb-all#dataset> ; > > ja:graph <#dnb-all> > > ]; > > ja:namedGraph [ > > ja:graphName <https://d-nb.info/datasets/zdb#dataset> ; > > ja:graph <#zdb> > > ]; > > . > > <#authorities> a tdb2:GraphTDB ; > > tdb2:GraphTDB2 OK. > > tdb2:dataset <#dataset-authorities> . > > tdb2:location works here but I also checked with: > > ## Graphs out of DB2. > > <#graph> rdf:type tdb2:GraphTDB2 ; > tdb2:graphName "urn:x-arq:UnionGraph" ; > tdb2:dataset <#DB2> ; > . > > <#graph2> rdf:type tdb2:GraphTDB2 ; > tdb2:graphName "https://example/ng1" ; > tdb2:dataset <#DB2> ; > . > <#graph3> rdf:type tdb2:GraphTDB2 ; > tdb2:graphName "https://example/ng" ; > tdb2:dataset <#DB2> ; > . > > <#DB2> rdf:type tdb2:DatasetTDB2 ; > tdb2:location "DB2" ; OK, thank you. I think I got the general pattern. That leaves me with the question how to import a set of n-triples into a specific graph in a TDB2 dataset. Thanks, Lars
