On 24/01/14 09:52, Rohana Rajapakse wrote:
Thanks Andy.

I am now trying to use GenericRuleReasoner. The tdb config is given below.
It works fine with data added to the default graph.
The query you sent me does not show any triples when I insert data into a
graph. I am not sure if the way I configure the inference engine is
correct. Can you please see what is wrong.

The defaultUnionGraph is a feature of SPARQL query processing - it's a read-only view of the data.

It does not apply to the API (because updates have to go to the real default graph) which is what the inference engine is using.

You might try using a named graph instead of ja:defaultGraph with a name of union: <urn:x-arq:UnionGraph> That gets you a read-only view similar to SPARQL (TDB actually does it differently for efficiency).

Inference uses memory so there may be scale issues here.

The other approach is to apply your rules while loading the data, expanding the triples once at load time - then at runtime, you are running with a non-inference dataset (which is faster).

        Andy



Data Insert Query:
==============

  PREFIX owl: <http://www.w3.org/2002/07/owl#>
  INSERT DATA {
   GRAPH <http://test>
     {
        <http://localhost:3030/resource/Kevin> foaf:lastName "Fernando" .
        <http://localhost:3030/resource/Peter> foaf:lastName "Fernando" .
        <http://localhost:3030/resource/Kevin2> foaf:lastName "Fernando" .
        <http://localhost:3030/resource/Kevin> owl:sameAs <
http://localhost:3030/resource/Peter> .
        <http://localhost:3030/resource/Peter> owl:sameAs <
http://localhost:3030/resource/Kevin2> .
    }
  }


Select Query:
==========

  PREFIX owl: <http://www.w3.org/2002/07/owl#>
  SELECT ?s ?s1 ?s2  {
    { ?s owl:sameAs ?o }
    UNION
       { GRAPH <urn:x-arq:DefaultGraph> { ?s1 owl:sameAs ?o1 } }
    UNION
      { GRAPH ?g2 { ?s2 owl:sameAs ?o2 } }
}


TDB Config file:
============

@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 tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] rdf:type fuseki:Server ;
    # Timeout - server-wide default: milliseconds.
    # Format 1: "1000" -- 1 second timeout
    # Format 2: "10000,60000" -- 10s timeout to first result, then 60s
timeout to for rest of query.
    # See java doc for ARQ.queryTimeout
    # ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "10000" ] ;
    # ja:loadClass "your.code.Class" ;
    fuseki:services (
   <#service_rulesinf>
    ) .

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

<#service_rulesinf>  rdf:type                               fuseki:Service ;
                    rdfs:label                             "TDB Service with
Generic Rule Reasoner" ;
                    fuseki:name                            "data"
;             # http://host/data
                    fuseki:serviceQuery                    "sparql"
;          # SPARQL query service
                    fuseki:serviceQuery                    "query" ;
                    fuseki:serviceUpdate                   "update" ;
                    fuseki:serviceUpload                   "upload" ;
                    fuseki:serviceReadWriteGraphStore      "data"  ;
                    fuseki:dataset        <#dataset> ;
      .
  <#dataset>   a   ja:RDFDataset;
               ja:defaultGraph [
                    a  ja:InfModel;
                   ja:reasoner [
                      ja:reasonerURL <
http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
                      ja:rulesFrom <file:inference_rules.rules> ;
                   ];
               ja:baseModel <#data_and_ontology_graph>
    ];
  .
  <#data_and_ontology_graph>   a             tdb:GraphTDB ;
                               tdb:location "MYTDB" ;
         # tdb:unionDefaultGraph true ;
  .

Rules File:
========
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@include <OWLMini>.
[rule1: (?S1 owl:sameAs ?S2),(?S2 owl:sameAs ?S3) ->(?S1 owl:sameAs ?S3) ]



On 23 January 2014 16:11, Andy Seaborne <a...@apache.org> wrote:

Hi Rohana,


<#tdb_dataset_read> rdf:type      tdb:DatasetTDB ;
      tdb:location "MYTDB" ;
      tdb:unionDefaultGraph true ;


<#tdb_dataset_readwrite> rdf:type      tdb:DatasetTDB ;
      tdb:location "MYTDB" ;
       .

The two descriptions of the datasets point to the same set of files so,
internally, there is one TDB dataset engine, which has to manage all
accesses.

"tdb:unionDefaultGraph true" is going to set a property of the engine, and
not be sensitive to the route used to name it, so it sets it on the shared
engine.  It will apply to both services.

Sorry that wasn't documented anywhere.

         Andy


On 23/01/14 15:06, Rohana Rajapakse wrote:

Hi Andy,

I have tested inserting and querying data using with two tdb
configs. Having "tdb:unionDefaultGraph true ;" in the config for read-only
endpoint
seems to affects the update endpoint.

*The queries I am using to insert data and query are:*


   PREFIX owl: <http://www.w3.org/2002/07/owl#>
   INSERT DATA {
       <http://localhost:3030/resource/Kevin> foaf:lastName "Fernando" .
      <http://localhost:3030/resource/Peter> foaf:lastName "Fernando" .
   }


PREFIX owl: <http://www.w3.org/2002/07/owl#>
select *
where {
   ?s ?p ?o .
}

I have tried the following tdb config with and without setting
tdb:unionDefaultGraph to true (in Fuseki web console against the dataset
"/data" which is my update endpoint). In both cases the insert data query
returns "Update succeeded" message. The select query, however, shown data
triples only when Fuseki
is run without setting tdb:unionDefaultGraph to true for READ-ONLY
endpoint. I am not useing that endpoint at all (but it is available). Note
they both use the same storage location "MYTDB".

*Here is the tdb config file:*


# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
## Example of a TDB dataset published using Fuseki: persistent storage.
@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 tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
[] rdf:type fuseki:Server ;
     # Timeout - server-wide default: milliseconds.
     # Format 1: "1000" -- 1 second timeout
     # Format 2: "10000,60000" -- 10s timeout to first result, then 60s
timeout to for rest of query.
     # See java doc for ARQ.queryTimeout
     # ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "10000" ]
;
     # ja:loadClass "your.code.Class" ;
     fuseki:services (
       <#service_tdb_read_only>
       <#service_tdb_all>
     ) .

# TDB
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .
## ---------------------------------------------------------------
## Read-only TDB dataset (only read services enabled).
<#service_tdb_read_only> rdf:type fuseki:Service ;
      rdfs:label                      "TDB Service (R)" ;
      fuseki:name                     "ds" ;             # http://host/ds
      fuseki:serviceQuery             "query" ;
      fuseki:serviceQuery             "sparql" ;
      # Don't allow SPARQL Update.
      #fuseki:serviceUpdate            "update" ;
      # Use the read-only service.
      fuseki:serviceReadGraphStore    "data" ;
      fuseki:serviceReadGraphStore    "get" ;
      fuseki:dataset           <#tdb_dataset_read> ;
      .

<#tdb_dataset_read> rdf:type      tdb:DatasetTDB ;
      tdb:location "MYTDB" ;
      tdb:unionDefaultGraph true ;  ##NOTE: I am trying with and without
this
line
      .

## ---------------------------------------------------------------
## Updatable TDB dataset with all services enabled.
<#service_tdb_all> rdf:type fuseki:Service ;
      rdfs:label                      "TDB Service (RW)" ;
      fuseki:name                     "data" ;   # http://host/data
      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           <#tdb_dataset_readwrite> ;
      .

<#tdb_dataset_readwrite> rdf:type      tdb:DatasetTDB ;
      tdb:location "MYTDB" ;
       .





On 22 January 2014 12:00, Andy Seaborne <a...@apache.org> wrote:

  On 22/01/14 11:34, Rohana Rajapakse wrote:

  Dear Andy,

you are absolutely correct. There is "tdb:unionDefaultGraph true ." in
the
config file for a different (read only) endpoint. It seems to affect the
entire datastore (not endpoint specific!)


It shouldn't - could you post the whole config file please ?

          Andy


  thanks

Rohana


On 22 January 2014 11:18, Rohana Rajapakse <
rohana.rajapa...@gossinteractive.com> wrote:

     Yes it works!


Can you please tell me what you mean by "running with default union
graph
on". I thought we always have a default graph, and if no named-graph is
specified in sparql (update or select) queries, the operations are
performed against the default graph, i.e. triples being inserted goes
in
the default graph and select queries return data in all graphs
(including
the default graph).

How can use change default union graph to off?

What exactly is the uri of the default graph?

Thanks

Rohana


-----Original Message-----
From: Andy Seaborne [mailto:a...@apache.org <a...@apache.org>]
Sent: 22 January 2014 11:09
To: users@jena.apache.org
Subject: Re: Default graph issue (tdb-backed Fuseki)

On 22/01/14 09:29, Rohana Rajapakse wrote:

  Hi,


Hi there,




I have a tdb-backed Fuseki installation. I am  inserting data using
INSERT DATA sparql query (also tried reading triple data from a file)
without giving a named-graph uri (with GRAPH keyword),


Did you just use the UI or load the data some other way as well?

   the query is executed

without errors and in the query forms of the Fuseki web console I see
the message “*Update succeeded*”, but a select query without giving a
named-graph (with GRAPH <…>) does not show the inserted triples.


Could you try this query please:

SELECT ?s ?s1 ?s2  {
      { ?s ?p ?o }
      UNION
      { GRAPH <urn:x-arq:DefaultGraph> { ?s1 ?p1 ?o1 } }
      UNION
      { GRAPH ?g2 { ?s2 ?p2 ?o2 } }
}

It looks like you are running with default union graph on - maybe it
was
set globally when the server was started.

           Andy

   It all works when I inserted data into a named-graph using the

GRAPH<…>



Can someone please let me know what is going on.



I am using Fuseki-1.0.0 with Jena-2.11.0



Here is the TDB config file:



<#service_tdb_all> rdf:type fuseki:Service ;

        rdfs:label                      "TDB Service (RW)" ;

        fuseki:name                     "data" ;

        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           <#tdb_dataset_readwrite> ;

        .



<#tdb_dataset_readwrite> rdf:type      tdb:DatasetTDB ;

        tdb:location "MYTDB" ;

        .





Thanks for any help.



Rohana




Keep up-to-date with best practice, new releases, webinars and more
with
our free newsletter:
http://www.gossinteractive.com/newsletter

Registered Office: 24 Darklake View, Estover, Plymouth, PL6 7TL.

Company Registration No: 3553908

This email contains proprietary information, some or all of which may
be
legally privileged. It is for the intended recipient only. If an
addressing
or transmission error has misdirected this email, please notify the
author
by replying to this email. If you are not the intended recipient you
may
not use, disclose, distribute, copy, print or rely on this email.

Email transmission cannot be guaranteed to be secure or error free, as
information may be intercepted, corrupted, lost, destroyed, arrive late
or
incomplete or contain viruses. This email and any files attached to it
have
been checked with virus detection software before transmission. You
should
nonetheless carry out your own virus check before opening any
attachment.
GOSS Interactive Ltd accepts no liability for any loss or damage that
may
be caused by software viruses.
    <#143b9ad660b1e235_>









Reply via email to