Hi there,

For my understanding here:
Is there a reason not to have a single TDB2 dataset with several graphs in it with "union graph" set?


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.

---- 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

     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" ;
    .


<#bib> a tdb2:GraphTDB ;
     tdb2:dataset <#dataset-bib> .
<#dnb-all> a tdb2:GraphTDB ;
     tdb2:dataset <#dataset-dnb-all> .
<#zdb> a tdb2:GraphTDB ;
     tdb2:dataset <#dataset-zdb> .

<#dataset-authorites> a tdb2:DatasetTDB ;
     tdb2:location "/home/svensson/fuseki-data/dnb/authorities/" .
<#dataset-bib> a tdb2:DatasetTDB ;
     tdb2:location "/home/svensson/fuseki-data/dnb/bib/" .
<#dataset-dnb-all> a tdb2:DatasetTDB ;
     tdb2:location "/home/svensson/fuseki-data/dnb/dnb-all/" .
<#dataset-zdb> a tdb2:DatasetTDB ;
     tdb2:location "/home/svensson/fuseki-data/dnb/zdb/" .

When I start Fuseki, I get the following error message:




[2019-01-15 11:14:13] Server     ERROR Exception in initialization: the root 
file:///home/svensson/apache-jena-fuseki-3.10.0/run/configuration/service1.ttl#authorities
 has no most specific type that is a subclass of ja:Object
[2019-01-15 11:14:13] WebAppContext WARN  Failed startup of context 
o.e.j.w.WebAppContext@46044faa{Apache Jena Fuseki 
Server,/,file:///home/svensson/apache-jena-fuseki-3.10.0/webapp/,UNAVAILABLE}
org.apache.jena.assembler.exceptions.NoSpecificTypeException: the root 
file:///home/svensson/apache-jena-fuseki-3.10.0/run/configuration/service1.ttl#authorities
 has no most specific type that is a subclass of ja:Object
   doing:
     root: 
file:///home/svensson/apache-jena-fuseki-3.10.0/run/configuration/service1.ttl#dnb
 with type: http://jena.hpl.hp.com/2005/11/Assembler#RDFDataset assembler 
class: class org.apache.jena.sparql.core.assembler.DatasetAssembler

Have I missed something obvious?

Thanks in advance,

Lars

Reply via email to