Barry,

You create a dataset that is comprised of the following:

defaultGraph -> unionModel
namedGraph(https://www.tno.nl/agrifood/graph/pizza/data)
namedGraph(https://www.tno.nl/agrifood/graph/pizza/onto)
<https://www.tno.nl/agrifood/graph/pizza/onto>


https://www.tno.nl/agrifood/graph/pizza/data is loaded from
file:src/main/resources/dummy1.ttl
https://www.tno.nl/agrifood/graph/pizza/onto is loaded from
file:src/main/resources/dummy2.ttl

defaultGraph is the union of two graphs
defaultGraph.root is loaded from file:src/main/resources/dummy1.ttl
defaultGraph.sub1 is loaded from file:src/main/resources/dummy2.ttl

writing triples into the dataset will write to the defaultGraph.  The
defaultGraph being a uniongraph will write to the first graph
(default.Graph.root).  While they are initialized with the same data
(file:src/main/resources/dummy1.ttl), this is not the same as the
https://www.tno.nl/agrifood/graph/pizza/data  named graph.

Your example basically has 4 graphs, 2 in defaultGraph and 2 named graphs.

Claude

On Fri, Sep 27, 2019 at 3:57 PM Nouwt, B. (Barry)
<barry.no...@tno.nl.invalid> wrote:

> Hi Claude, thanks for the explanation: from the dataset-as-quads
> perspective it does indeed sound logical that empty graphs do not exist.
>
> Regarding your second answer, I've added some additional information below
> (i.e. these can also be found on the github repo:
> https://github.com/barrynl/jena-example). The SPARQL is executed on the
> dataset described by the conf.ttl below. It does not have a GRAPH specified
> in the query and it would indeed go into the default graph, which is a
> UnionModel of the two in-memory named graphs. Of which the rootGraph should
> store this new data. The details of how I inspect the different graphs can
> be found in the Java code in the link above. If you run this example and
> inspect the output log and 'dataset' variable (and the inner models and
> graphs) with a debugger, the data sometimes shows up and sometimes doesn't.
> I am trying to understand why... Any more ideas?
>
> Regards, Barry
>
> ---------------------------------------- SPARQL
> ----------------------------------------
> INSERT DATA {
>                 :test rdf:type pizza:Pizza .
>                 :test pizza:hasCountryOfOrigin <
> http://192.168.99.100/pizza/Italy> .
>                 :test pizza:hasBase <http://192.168.99.100/pizza/23_base>
> .
>                 :test pizza:hasSpiciness <
> http://192.168.99.100/pizza/23_flauw> .
>                 :test pizza:hasTopping :18-Tomaat .
>                 :test pizza:hasTopping :18-mozzerella .
>                 :test pizza:hasTopping :18-rundergehakt .
> }
>
> ---------------------------------------- conf.ttl
> ----------------------------------------
>
> @prefix : <#> .
> @prefix fuseki: <http://jena.apache.org/fuseki#<
> http://jena.apache.org/fuseki>> .
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#<
> http://www.w3.org/1999/02/22-rdf-syntax-ns>> .
> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#<
> http://www.w3.org/2000/01/rdf-schema>> .
> @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#<
> http://jena.hpl.hp.com/2005/11/Assembler>> .
> @prefix xsd: <http://www.w3.org/2001/XMLSchema#<
> http://www.w3.org/2001/XMLSchema>>  .
>
> :service1 rdf:type fuseki:Service ;
>         fuseki:name "test" ;
>         fuseki:serviceQuery "query" ; # SPARQL query service
>         fuseki:serviceUpdate "update" ;
>         fuseki:serviceUpload "upload" ; # Non-SPARQL upload service
>         fuseki:serviceReadWriteGraphStore "data" ; # SPARQL Graph store
> protocol (read and write)
>         # A separate read-only graph store endpoint:
>         fuseki:serviceReadGraphStore "get" ; # SPARQL Graph store protocol
> (read only)
>         fuseki:dataset :dataset .
>
> :dataset rdf:type ja:RDFDataset ;
>         ja:defaultGraph :unionModel ;
>         ja:namedGraph
>         [ ja:graphName      <https://www.tno.nl/agrifood/graph/pizza/data>
> ;
>           ja:graph          :itemGraph ] ;
>         ja:namedGraph
>         [ ja:graphName      <https://www.tno.nl/agrifood/graph/pizza/onto>
> ;
>           ja:graph          :ontoGraph ]
>      .
>
> :unionModel rdf:type ja:UnionModel ;
>         ja:rootModel :itemGraph ;
>         ja:subModel :ontoGraph .
>
> :itemGraph rdf:type ja:MemoryModel ;
>         ja:content [ ja:externalContent
> <file:src/main/resources/dummy1.ttl> ] .
>
> :ontoGraph rdf:type ja:MemoryModel ;
>         ja:content [ ja:externalContent
> <file:src/main/resources/dummy2.ttl> ] .
>
>
>
>
> -----Original Message-----
> From: Claude Warren <cla...@xenei.com>
> Sent: donderdag 26 september 2019 12:10
> To: users@jena.apache.org
> Subject: Re: [UnionModel] question about unexpected behaviour
>
> Empty graphs in Fuseki simply don't exist.  They no more exist than a
> predicate that has not been used.  Named graphs only come into existence
> when there is at least one triple added to it.  If you think about datasets
> as collections of quads (<g> <s> <p> <o>) then you can see that the dataset
> can only locate graphs that have data.  The only other option is that an
> infinite number of graphs exist, in which case listing all the graphs would
> be impossible.  I am sure there is a deep philosophical discussion here but
> the Jena  rule is that if the graph does not have data it does not exist.
>
> As for your second question, you did not give an example of how you
> inserted the data.  If you did not provide a graph name to insert into then
> the data would go into the default graph named "urn:x-arq:DefaultGraph"
> (defined in org.apache.jena.sparql.core.Quad.defaultGraphIRI).  If you did
> provide the graph name then the data would be inserted into that graph as
> your debugging shows.  When you say it does not exist in the graph are you
> referring to on disk?  How did you write the data back out?  The UnionModel
> depends on the underlying models to preserve their data.  If those models
> are in-memory models then they will not be written back to disk, if they
> are TDB models (or other similar auto storing models) then they should  be
> written back to the underlying storage.  This assumes that all transactions
> and other issues are correctly handled.
>
> Claude
>
>
>
> On Thu, Sep 26, 2019 at 10:05 AM Nouwt, B. (Barry)
> <barry.no...@tno.nl.invalid> wrote:
>
> > Hi all,
> >
> > I am trying to get the Apache Jena UnionModel working for my scenario,
> > but I keep encountering unexpected behavior. I've set up a minimal,
> > free-standing example on github in this repository (clone the git
> > repo, configure Maven in your IDE and execute the main() method, I.e.
> > it probably does not run from the .jar):
> >
> >  https://github.com/barrynl/jena-example
> >
> >
> >
> > I have two questions related to this example:
> >
> > My first question is related to empty graphs in Jena Fuseki. If I load
> > the conf.ttl (from the git repo above) at startup in Apache Jena
> > Fuseki without the dummy data in the two named graphs, the two graphs
> > seem to disappear (I think this does not happen in my Java Example). I
> > read somewhere that empty graphs are automatically deleted in Fuseki
> > to prevent old graphs from showing up in the Fuseki interface. For my
> > use case I would like to configure two (possibly empty at first) named
> > graphs via a conf.ttl and be able to store data in them afterwards. Is
> this possible?
> >
> > My second question is about the demonstraded behaviour of the Java
> > example in the git repository above. I load a dataset with a
> > UnionModel from a conf.ttl file and insert new data in it via SPARQL.
> > Although the new data shows up in the select query, it does not show
> > up in either of the two names graphs the UnionModel consists of. My
> > question is: where is this data stored if not in one of the names
> > graphs? (If I inspect the UnionModel via a debugger, the inserted data
> > DOES show up in the correct named graph)
> >
> > Hopefully someone can shed some light on this behaviour. Thanks in
> advance!
> >
> > Regards, Barry
> > This message may contain information that is not intended for you. If
> > you are not the addressee or if this message was sent to you by
> > mistake, you are requested to inform the sender and delete the
> > message. TNO accepts no liability for the content of this e-mail, for
> > the manner in which you use it and for damage of any kind resulting
> > from the risks inherent to the electronic transmission of messages.
> >
>
>
> --
> I like: Like Like - The likeliest place on the web <
> http://like-like.xenei.com>
> LinkedIn: http://www.linkedin.com/in/claudewarren
>


-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Reply via email to