Discussion:
Persisting named graphs in TDB with jena-fuseki
Maxim Kolchin
2016-03-09 17:21:42 UTC
Permalink
Hi,

(This is a response to the thread which ended in 2014 with [0] mail)

I have the same problem which was discussed in this thread and also
there is the same question on StackOverflow [1], so it means that at
least three persons in the world has or had this problem.

I managed to configure Fuseki to store every named graph in TDB. Here
is a minimal configuration (Fuseki 2.3.1 is used):

[] a fuseki:Server ;
fuseki:services ( <#service1> ) .

<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .

<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" .

The other part of the question (which I did not find a answer to) is
how to enable reasoning on the default and all named graphs? Or at
least on the default graph?

I already tried different combinations, but without any success, one
of them is the following:
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .

<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .

<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" ;
ja:defaultGraph <#infModel> .

<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#dataset> .

<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ;
] .

[0]: http://mail-archives.apache.org/mod_mbox/jena-users/201405.mbox/%***@gmail.com%3E
[1]: http://stackoverflow.com/questions/35428064/reasoning-with-fuseki-tdb-and-named-graphs

Thank you in advance!
Maxim Kolchin
PhD Student @ ITMO University (National Research University)
E-mail: ***@gmail.com
Tel.: +7 (911) 199-55-73
Homepage: http://kolchinmax.ru
Rob Vesse
2016-03-10 09:28:56 UTC
Permalink
You seem to have a circular reference in your setup so I am surprised it
does anything at all

<#dataset> references <#infModel> which references <#tdbGraph> which
references <#dataset>

So what I think is happening is that one of declarations is getting ignored

If you look in the distribution you should see an example called
config-inf-tdb.ttl where you can see how to configure this. The key is
that you need to declare a general dataset with a default graph of the
inference model which is then backed by a separate TDB dataset declaration

Rob
Post by Maxim Kolchin
Hi,
(This is a response to the thread which ended in 2014 with [0] mail)
I have the same problem which was discussed in this thread and also
there is the same question on StackOverflow [1], so it means that at
least three persons in the world has or had this problem.
I managed to configure Fuseki to store every named graph in TDB. Here
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" .
The other part of the question (which I did not find a answer to) is
how to enable reasoning on the default and all named graphs? Or at
least on the default graph?
I already tried different combinations, but without any success, one
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" ;
ja:defaultGraph <#infModel> .
<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#dataset> .
<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ;
] .
http://mail-archives.apache.org/mod_mbox/jena-users/201405.mbox/%3C53711D5
http://stackoverflow.com/questions/35428064/reasoning-with-fuseki-tdb-and-
named-graphs
Thank you in advance!
Maxim Kolchin
Tel.: +7 (911) 199-55-73
Homepage: http://kolchinmax.ru
Maxim Kolchin
2016-03-10 10:55:48 UTC
Permalink
Hi Rob,

Yes, it works that way (from [0]), but the problem is that newly
created named graphs (created with INSERT query) are not stored on the
disk, i.e. after restart the named graphs disappear.

[0]: https://github.com/apache/jena/blob/master/jena-fuseki1/config-inf-tdb.ttl

Maxim
Post by Rob Vesse
You seem to have a circular reference in your setup so I am surprised it
does anything at all
<#dataset> references <#infModel> which references <#tdbGraph> which
references <#dataset>
So what I think is happening is that one of declarations is getting ignored
If you look in the distribution you should see an example called
config-inf-tdb.ttl where you can see how to configure this. The key is
that you need to declare a general dataset with a default graph of the
inference model which is then backed by a separate TDB dataset declaration
Rob
Post by Maxim Kolchin
Hi,
(This is a response to the thread which ended in 2014 with [0] mail)
I have the same problem which was discussed in this thread and also
there is the same question on StackOverflow [1], so it means that at
least three persons in the world has or had this problem.
I managed to configure Fuseki to store every named graph in TDB. Here
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" .
The other part of the question (which I did not find a answer to) is
how to enable reasoning on the default and all named graphs? Or at
least on the default graph?
I already tried different combinations, but without any success, one
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" ;
ja:defaultGraph <#infModel> .
<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#dataset> .
<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ;
] .
http://mail-archives.apache.org/mod_mbox/jena-users/201405.mbox/%3C53711D5
http://stackoverflow.com/questions/35428064/reasoning-with-fuseki-tdb-and-
named-graphs
Thank you in advance!
Maxim Kolchin
Tel.: +7 (911) 199-55-73
Homepage: http://kolchinmax.ru
Rob Vesse
2016-03-10 14:47:10 UTC
Permalink
Well that wasn't the question you asked!

This is because updates go into the general dataset which is in-memory and
non-persistent and not the persistent TDB dataset which backs the
configured default graph

The workaround for that is to define two different services, one for query
which uses the inference dataset and one for update that uses the TDB
dataset directly and direct queries and updates to the two different
services

AFAIK there is no way to have a single dataset definition with your
desired behaviour currently though I could be wrong

Rob
Post by Maxim Kolchin
Hi Rob,
Yes, it works that way (from [0]), but the problem is that newly
created named graphs (created with INSERT query) are not stored on the
disk, i.e. after restart the named graphs disappear.
https://github.com/apache/jena/blob/master/jena-fuseki1/config-inf-tdb.ttl
Maxim
Post by Rob Vesse
You seem to have a circular reference in your setup so I am surprised it
does anything at all
<#dataset> references <#infModel> which references <#tdbGraph> which
references <#dataset>
So what I think is happening is that one of declarations is getting ignored
If you look in the distribution you should see an example called
config-inf-tdb.ttl where you can see how to configure this. The key is
that you need to declare a general dataset with a default graph of the
inference model which is then backed by a separate TDB dataset declaration
Rob
Post by Maxim Kolchin
Hi,
(This is a response to the thread which ended in 2014 with [0] mail)
I have the same problem which was discussed in this thread and also
there is the same question on StackOverflow [1], so it means that at
least three persons in the world has or had this problem.
I managed to configure Fuseki to store every named graph in TDB. Here
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" .
The other part of the question (which I did not find a answer to) is
how to enable reasoning on the default and all named graphs? Or at
least on the default graph?
I already tried different combinations, but without any success, one
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" ;
ja:defaultGraph <#infModel> .
<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#dataset> .
<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL
<http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>
;
] .
http://mail-archives.apache.org/mod_mbox/jena-users/201405.mbox/%3C53711
D5
http://stackoverflow.com/questions/35428064/reasoning-with-fuseki-tdb-an
d-
named-graphs
Thank you in advance!
Maxim Kolchin
Tel.: +7 (911) 199-55-73
Homepage: http://kolchinmax.ru
Maxim Kolchin
2016-03-10 15:14:38 UTC
Permalink
Post by Rob Vesse
Well that wasn't the question you asked!
Sorry, if I wasn't clear enough.
Post by Rob Vesse
The workaround for that is to define two different services, one for query which uses the inference dataset and one for update that uses the TDB dataset directly and direct queries and updates to the two different services.
I tried the configuration presented below and it works for me as a
workaround. Is it similar to what you propose?

[] a fuseki:Server ;
fuseki:services ( <#service1> <#service2> ) ;
.
<#service1> a fuseki:Service ;
fuseki:name "default" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#defaultDataset> ;
.
<#defaultDataset> a ja:RDFDataset ;
ja:defaultGraph <#infModel> ;
.
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "/etc/fuseki/databases/fuseki-db/default" ;
.

<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#tdbDataset> ;
.

<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ;
] ;
.
<#service2> a fuseki:Service ;
fuseki:name "private" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:dataset <#privateDataset> ;
.

<#privateDataset> rdf:type tdb:DatasetTDB ;
tdb:location "/etc/fuseki/databases/fuseki-db/private" ;
.
Post by Rob Vesse
AFAIK there is no way to have a single dataset definition with your desired behaviour currently though I could be wrong.
Does it make sense to create a feature request? Maybe there exists
such issue already?

Thank you!
Maxim
Post by Rob Vesse
Well that wasn't the question you asked!
This is because updates go into the general dataset which is in-memory and
non-persistent and not the persistent TDB dataset which backs the
configured default graph
The workaround for that is to define two different services, one for query
which uses the inference dataset and one for update that uses the TDB
dataset directly and direct queries and updates to the two different
services
AFAIK there is no way to have a single dataset definition with your
desired behaviour currently though I could be wrong
Rob
Post by Maxim Kolchin
Hi Rob,
Yes, it works that way (from [0]), but the problem is that newly
created named graphs (created with INSERT query) are not stored on the
disk, i.e. after restart the named graphs disappear.
https://github.com/apache/jena/blob/master/jena-fuseki1/config-inf-tdb.ttl
Maxim
Post by Rob Vesse
You seem to have a circular reference in your setup so I am surprised it
does anything at all
<#dataset> references <#infModel> which references <#tdbGraph> which
references <#dataset>
So what I think is happening is that one of declarations is getting ignored
If you look in the distribution you should see an example called
config-inf-tdb.ttl where you can see how to configure this. The key is
that you need to declare a general dataset with a default graph of the
inference model which is then backed by a separate TDB dataset declaration
Rob
Post by Maxim Kolchin
Hi,
(This is a response to the thread which ended in 2014 with [0] mail)
I have the same problem which was discussed in this thread and also
there is the same question on StackOverflow [1], so it means that at
least three persons in the world has or had this problem.
I managed to configure Fuseki to store every named graph in TDB. Here
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" .
The other part of the question (which I did not find a answer to) is
how to enable reasoning on the default and all named graphs? Or at
least on the default graph?
I already tried different combinations, but without any success, one
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" ;
ja:defaultGraph <#infModel> .
<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#dataset> .
<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL
<http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>
;
] .
http://mail-archives.apache.org/mod_mbox/jena-users/201405.mbox/%3C53711
D5
http://stackoverflow.com/questions/35428064/reasoning-with-fuseki-tdb-an
d-
named-graphs
Thank you in advance!
Maxim Kolchin
Tel.: +7 (911) 199-55-73
Homepage: http://kolchinmax.ru
Andy Seaborne
2016-03-18 15:50:59 UTC
Permalink
https://issues.apache.org/jira/browse/JENA-1122
(resolved)

looks relevant here. It is not in any release, only in development builds.

It should support <#service1> and <#service2> having the same inference
dataset.


The case of a shared TDB databases does (should) work in a release but
not where one is an inference wrapped setup. Changes to the database
that bypass the inference machinery will not show up in forward rules
and I'm not clear if they will in all cases in backwards rules.

Andy
Post by Maxim Kolchin
Post by Rob Vesse
Well that wasn't the question you asked!
Sorry, if I wasn't clear enough.
Post by Rob Vesse
The workaround for that is to define two different services, one for query which uses the inference dataset and one for update that uses the TDB dataset directly and direct queries and updates to the two different services.
I tried the configuration presented below and it works for me as a
workaround. Is it similar to what you propose?
[] a fuseki:Server ;
fuseki:services ( <#service1> <#service2> ) ;
.
<#service1> a fuseki:Service ;
fuseki:name "default" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#defaultDataset> ;
.
<#defaultDataset> a ja:RDFDataset ;
ja:defaultGraph <#infModel> ;
.
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "/etc/fuseki/databases/fuseki-db/default" ;
.
<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#tdbDataset> ;
.
<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> ;
] ;
.
<#service2> a fuseki:Service ;
fuseki:name "private" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:dataset <#privateDataset> ;
.
<#privateDataset> rdf:type tdb:DatasetTDB ;
tdb:location "/etc/fuseki/databases/fuseki-db/private" ;
.
Post by Rob Vesse
AFAIK there is no way to have a single dataset definition with your desired behaviour currently though I could be wrong.
Does it make sense to create a feature request? Maybe there exists
such issue already?
Thank you!
Maxim
Post by Rob Vesse
Well that wasn't the question you asked!
This is because updates go into the general dataset which is in-memory and
non-persistent and not the persistent TDB dataset which backs the
configured default graph
The workaround for that is to define two different services, one for query
which uses the inference dataset and one for update that uses the TDB
dataset directly and direct queries and updates to the two different
services
AFAIK there is no way to have a single dataset definition with your
desired behaviour currently though I could be wrong
Rob
Post by Maxim Kolchin
Hi Rob,
Yes, it works that way (from [0]), but the problem is that newly
created named graphs (created with INSERT query) are not stored on the
disk, i.e. after restart the named graphs disappear.
https://github.com/apache/jena/blob/master/jena-fuseki1/config-inf-tdb.ttl
Maxim
Post by Rob Vesse
You seem to have a circular reference in your setup so I am surprised it
does anything at all
<#dataset> references <#infModel> which references <#tdbGraph> which
references <#dataset>
So what I think is happening is that one of declarations is getting ignored
If you look in the distribution you should see an example called
config-inf-tdb.ttl where you can see how to configure this. The key is
that you need to declare a general dataset with a default graph of the
inference model which is then backed by a separate TDB dataset declaration
Rob
Post by Maxim Kolchin
Hi,
(This is a response to the thread which ended in 2014 with [0] mail)
I have the same problem which was discussed in this thread and also
there is the same question on StackOverflow [1], so it means that at
least three persons in the world has or had this problem.
I managed to configure Fuseki to store every named graph in TDB. Here
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" .
The other part of the question (which I did not find a answer to) is
how to enable reasoning on the default and all named graphs? Or at
least on the default graph?
I already tried different combinations, but without any success, one
[] a fuseki:Server ;
fuseki:services ( <#service1> ) .
<#service1> a fuseki:Service ;
fuseki:name "ds" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceQuery "query" ;
fuseki:dataset <#dataset> .
<#dataset> rdf:type tdb:DatasetTDB ;
tdb:location "./fuseki-db" ;
ja:defaultGraph <#infModel> .
<#tdbGraph> a tdb:GraphTDB ;
tdb:dataset <#dataset> .
<#infModel> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL
<http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>
;
] .
http://mail-archives.apache.org/mod_mbox/jena-users/201405.mbox/%3C53711
D5
http://stackoverflow.com/questions/35428064/reasoning-with-fuseki-tdb-an
d-
named-graphs
Thank you in advance!
Maxim Kolchin
Tel.: +7 (911) 199-55-73
Homepage: http://kolchinmax.ru
Loading...