You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Sushanth Vaddaram <su...@gmail.com> on 2020/12/03 17:47:16 UTC

Jena Performance Issue with Reasoner

We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.

Query:

PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#> 
PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#> 
PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX owl: <http://www.w3.org/2002/07/owl#> 

SELECT DISTINCT 
  ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
WHERE 
{
 { 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> . 
 ?datapointURI  rdf:type   ?datapointTYPE . 
 } 
	UNION
 { 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> . 
 ?datapointURI  rdfs:label   ?datapointLABEL . 
 } 
	UNION
 { 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> . 
 ?datapointURI  dip:data_source_url   ?datapointDATAMOD . 
 } 
	UNION
 { 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM . 
 } 
	UNION
 { 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 } 
	UNION
 { 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> . 
 ?datapointURI  dip:abstracts   ?datapointABSTPROP . 
 } 
{


SELECT DISTINCT 
  ?datapointURI
WHERE 
{
 { 
 ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> . 
 ?zoneURI  dip:has_scene_property   ?zonePROP . 
 ?datapointURI  dip:abstracts   ?zonePROP . 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 } 
	UNION
 { 
<http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI . 
 ?deviceURI  dip:provides_info_object   ?datapointURI . 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 } 
	UNION
 { 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 ?datapointPROVIDER  dip:provides_info_object   ?datapointURI . 
 ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> . 
<http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI . 
 ?deviceURI  dip:provides_info_object   ?datapointURI . 
 ?datapointURI  rdf:type   dip:DataPoint  . 
 } 
}

}
}



Configuration:
==========
@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 tdb2:  <http://jena.apache.org/2016/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .

[] rdf:type fuseki:Server ;
   fuseki:services (	    
     <#dip>
   ) .

# TDB
#[] ja:loadClass "org.apache.jena.tdb.TDB" .
#tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
#tdb:GraphTDB    rdfs:subClassOf  ja:Model .

## ---------------------------------------------------------------

<#dip> rdf:type fuseki:Service ;
    # URI of the dataset -- http://host:port/dip 
    fuseki:name                        "dip" ; 
    fuseki:serviceQuery                "sparql" ;
    fuseki:serviceQuery                "query" ;
    fuseki:serviceUpdate               "update" ;
    fuseki:serviceUpload               "upload" ;
    fuseki:serviceReadWriteGraphStore  "data" ;     
    fuseki:serviceReadGraphStore       "get" ;
    fuseki:dataset                     <#dip_tbd> ;
    .

#TBD
<#dip_tbd> rdf:type ja:RDFDataset ;
     ja:defaultGraph <#infModel>  ;	 
	 tdb:fileMode "direct" ;
	 .

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

<#tdbGraph>  rdf:type tdb2:GraphTDB ;
	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
	tdb2:unionDefaultGraph true ;

	.


Thanks for the help!!!

Re: Jena Performance Issue with Reasoner

Posted by Sushanth Vaddaram <su...@gmail.com>.
Hi Andy,

if you can provide any page which provides details about configuring memory dataset with a reasoner will help.

Thanks!!

On 2020/12/07 03:28:17, Sushanth Vaddaram <su...@gmail.com> wrote: 
> Hi Andy,
> 
> I tried the below config for having memory dataset with reasoner but the server doesn't start with the configuration
> 
> @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> 
> [] rdf:type fuseki:Server ;
>    fuseki:services (	    
>      <#dip>
>    ) .
> 
> # TDB
> #[] ja:loadClass "org.apache.jena.tdb.TDB" .
> #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> 
> ## ---------------------------------------------------------------
> 
> <#dip> rdf:type fuseki:Service ;
>     # URI of the dataset -- http://host:port/dip 
>     fuseki:name                        "dip" ; 
>     fuseki:serviceQuery                "sparql" ;
>     fuseki:serviceQuery                "query" ;
>     fuseki:serviceUpdate               "update" ;
>     fuseki:serviceUpload               "upload" ;
>     fuseki:serviceReadWriteGraphStore  "data" ;     
>     fuseki:serviceReadGraphStore       "get" ;
>     fuseki:dataset                     <#dip_tbd> ;
>     .
> 
> #TBD
> <#dip_tbd> rdf:type ja:RDFDataset ;
>      ja:defaultGraph <#infModel>  ;	 
> 	 tdb:fileMode "direct" ;
> 	 .
> 
> <#infModel>  a ja:InfModel ;
>       ja:baseModel <#tdbGraph>;
>       ja:reasoner
>          [ja:reasonerURL
>              <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
> 
> <#tdbGraph>  rdf:type tdb:GraphTDB ;
> 	#tdb2:location "C:\\etc\\fuseki/databases/dip" ;
> 	#tdb2:unionDefaultGraph true ;
> 	tdb:dataset <#tdbDataset> ;
> 	.
> 	
> <#tdbDataset> rdf:type tdb:DatasetTDB ;	
> 	tdb:unionDefaultGraph true ;
> 	tdb:location "C:\\etc\\fuseki/databases/dip" ;
> 	.
> 
> Thanks for the help!!!!
> 
> 
> 
> On 2020/12/06 10:09:58, Andy Seaborne <an...@apache.org> wrote: 
> > Please say what the error is and show the configuration you are trying.
> > 
> >      Andy
> > 
> > PS The config below has a lot of unnecessary items.
> > 
> > On 06/12/2020 01:18, Sushanth Vaddaram wrote:
> > > I tried the following dataset for In-memory but when trying to add reasoner, the server does not start. Can some some one please provide the configuration we can use for in-memory dataset with a reasoner.
> > > 
> > > Config
> > > =====
> > > 
> > > @prefix :      <http://base/#> .
> > > @prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
> > > @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> > > @prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
> > > @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
> > > @prefix fuseki: <http://jena.apache.org/fuseki#> .
> > > 
> > > <http://jena.apache.org/2016/tdb#DatasetTDB>
> > >          rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > ja:DatasetTxnMem  rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > :service1  a                          fuseki:Service ;
> > >          fuseki:dataset                :dataset ;
> > >          fuseki:name                   "dip10" ;
> > >          fuseki:serviceQuery           "" , "query" , "sparql" ;
> > >          fuseki:serviceReadGraphStore  "get" ;
> > >          fuseki:serviceReadQuads       "" ;
> > >          fuseki:serviceReadWriteGraphStore
> > >                  "data" ;
> > >          fuseki:serviceReadWriteQuads  "" ;
> > >          fuseki:serviceUpdate          "update" , "" ;
> > >          fuseki:serviceUpload          "upload" .
> > > 
> > > tdb:GraphTDB  rdfs:subClassOf  ja:Model .
> > > 
> > > <http://jena.apache.org/2016/tdb#GraphTDB2>
> > >          rdfs:subClassOf  ja:Model .
> > > 
> > > ja:MemoryDataset  rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > ja:RDFDatasetZero  rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > <http://jena.apache.org/text#TextDataset>
> > >          rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > <http://jena.apache.org/2016/tdb#GraphTDB>
> > >          rdfs:subClassOf  ja:Model .
> > > 
> > > ja:RDFDatasetOne  rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > ja:RDFDatasetSink  rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > :dataset  a     ja:DatasetTxnMem .
> > > 
> > > <http://jena.apache.org/2016/tdb#DatasetTDB2>
> > >          rdfs:subClassOf  ja:RDFDataset .
> > > 
> > > 
> > > On 2020/12/04 08:31:36, Andy Seaborne <an...@apache.org> wrote:
> > >>
> > >>
> > >> On 04/12/2020 02:52, Sushanth Vaddaram wrote:
> > >>> Thanks Dave.
> > >>>
> > >>> If we go with in-memory dataset, will I be loosing the data between jena restarts?
> > >>
> > >> Yes.
> > >>
> > >> You can write the data out to a file after computing and reload from
> > >> that - or write the materialised data to second TDB database and work
> > >> from that.
> > >>
> > >> The first part of the query could be rewritten - the first three triple
> > >> patterns are the same in each branch:
> > >>
> > >> WHERE {
> > >> ?datapointURI  rdf:type   dip:DataPoint  .
> > >> ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >> ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>
> > >> {
> > >> ?datapointURI  rdf:type   ?datapointTYPE .
> > >> } UNION {
> > >>    ?datapointURI  rdfs:label   ?datapointLABEL .
> > >> } UNION {
> > >> ....
> > >> }
> > >>
> > >> and it may help to reorder to put the SELECT DISTNCT first.
> > >>
> > >>       Andy
> > >>
> > >>>
> > >>> Thanks,
> > >>> Sushanth
> > >>>
> > >>> On 2020/12/03 19:13:58, Dave Reynolds <da...@gmail.com> wrote:
> > >>>> Hi,
> > >>>>
> > >>>> If your data doesn't change then yes you can compute the results ahead
> > >>>> of time. Set up your data and reasoner, write the whole resulting model
> > >>>> out to a dump file. Then you can load that dump file into another TDB
> > >>>> and serve it as a fuseki dataset with no reasoner configuration.
> > >>>>
> > >>>> That doesn't help if your data is continuously changing though.
> > >>>>
> > >>>> The other option would be to run in-memory instead of from TDB. Given
> > >>>> the reasoners are intrinsically limited to data that fits in memory then
> > >>>> would could switch to running in memory, reading the data in from files
> > >>>> when fuseki starts up. That would mean start up is slow but the reasoner
> > >>>> performance will be a little better.
> > >>>>
> > >>>> If neither of those options work or are open to you then I'm afraid it
> > >>>> may simply be that the reasoner is not up to the job.
> > >>>>
> > >>>> Dave
> > >>>>
> > >>>> On 03/12/2020 17:47, Sushanth Vaddaram wrote:
> > >>>>> We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.
> > >>>>>
> > >>>>> Query:
> > >>>>>
> > >>>>> PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#>
> > >>>>> PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#>
> > >>>>> PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#>
> > >>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> > >>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> > >>>>> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> > >>>>>
> > >>>>> SELECT DISTINCT
> > >>>>>      ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
> > >>>>> WHERE
> > >>>>> {
> > >>>>>     {
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>>>>     ?datapointURI  rdf:type   ?datapointTYPE .
> > >>>>>     }
> > >>>>> 	UNION
> > >>>>>     {
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>>>>     ?datapointURI  rdfs:label   ?datapointLABEL .
> > >>>>>     }
> > >>>>> 	UNION
> > >>>>>     {
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>>>>     ?datapointURI  dip:data_source_url   ?datapointDATAMOD .
> > >>>>>     }
> > >>>>> 	UNION
> > >>>>>     {
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM .
> > >>>>>     }
> > >>>>> 	UNION
> > >>>>>     {
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     }
> > >>>>> 	UNION
> > >>>>>     {
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>>>>     ?datapointURI  dip:abstracts   ?datapointABSTPROP .
> > >>>>>     }
> > >>>>> {
> > >>>>>
> > >>>>>
> > >>>>> SELECT DISTINCT
> > >>>>>      ?datapointURI
> > >>>>> WHERE
> > >>>>> {
> > >>>>>     {
> > >>>>>     ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> .
> > >>>>>     ?zoneURI  dip:has_scene_property   ?zonePROP .
> > >>>>>     ?datapointURI  dip:abstracts   ?zonePROP .
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     }
> > >>>>> 	UNION
> > >>>>>     {
> > >>>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI .
> > >>>>>     ?deviceURI  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     }
> > >>>>> 	UNION
> > >>>>>     {
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > >>>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI .
> > >>>>>     ?deviceURI  dip:provides_info_object   ?datapointURI .
> > >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> > >>>>>     }
> > >>>>> }
> > >>>>>
> > >>>>> }
> > >>>>> }
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> Configuration:
> > >>>>> ==========
> > >>>>> @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
> > >>>>> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> > >>>>>
> > >>>>> [] rdf:type fuseki:Server ;
> > >>>>>       fuseki:services (	
> > >>>>>         <#dip>
> > >>>>>       ) .
> > >>>>>
> > >>>>> # TDB
> > >>>>> #[] ja:loadClass "org.apache.jena.tdb.TDB" .
> > >>>>> #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> > >>>>> #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> > >>>>>
> > >>>>> ## ---------------------------------------------------------------
> > >>>>>
> > >>>>> <#dip> rdf:type fuseki:Service ;
> > >>>>>        # URI of the dataset -- http://host:port/dip
> > >>>>>        fuseki:name                        "dip" ;
> > >>>>>        fuseki:serviceQuery                "sparql" ;
> > >>>>>        fuseki:serviceQuery                "query" ;
> > >>>>>        fuseki:serviceUpdate               "update" ;
> > >>>>>        fuseki:serviceUpload               "upload" ;
> > >>>>>        fuseki:serviceReadWriteGraphStore  "data" ;
> > >>>>>        fuseki:serviceReadGraphStore       "get" ;
> > >>>>>        fuseki:dataset                     <#dip_tbd> ;
> > >>>>>        .
> > >>>>>
> > >>>>> #TBD
> > >>>>> <#dip_tbd> rdf:type ja:RDFDataset ;
> > >>>>>         ja:defaultGraph <#infModel>  ;	
> > >>>>> 	 tdb:fileMode "direct" ;
> > >>>>> 	 .
> > >>>>>
> > >>>>> <#infModel>  a ja:InfModel ;
> > >>>>>          ja:baseModel <#tdbGraph>;
> > >>>>>          ja:reasoner
> > >>>>>             [ja:reasonerURL
> > >>>>>                 <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
> > >>>>>
> > >>>>> <#tdbGraph>  rdf:type tdb2:GraphTDB ;
> > >>>>> 	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
> > >>>>> 	tdb2:unionDefaultGraph true ;
> > >>>>>
> > >>>>> 	.
> > >>>>>
> > >>>>>
> > >>>>> Thanks for the help!!!
> > >>>>>
> > >>>>
> > >>
> > 
> 

Re: Jena Performance Issue with Reasoner

Posted by Sushanth Vaddaram <su...@gmail.com>.
Hi Andy,

I tried the below config for having memory dataset with reasoner but the server doesn't start with the configuration

@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 tdb2:  <http://jena.apache.org/2016/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .

[] rdf:type fuseki:Server ;
   fuseki:services (	    
     <#dip>
   ) .

# TDB
#[] ja:loadClass "org.apache.jena.tdb.TDB" .
#tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
#tdb:GraphTDB    rdfs:subClassOf  ja:Model .

## ---------------------------------------------------------------

<#dip> rdf:type fuseki:Service ;
    # URI of the dataset -- http://host:port/dip 
    fuseki:name                        "dip" ; 
    fuseki:serviceQuery                "sparql" ;
    fuseki:serviceQuery                "query" ;
    fuseki:serviceUpdate               "update" ;
    fuseki:serviceUpload               "upload" ;
    fuseki:serviceReadWriteGraphStore  "data" ;     
    fuseki:serviceReadGraphStore       "get" ;
    fuseki:dataset                     <#dip_tbd> ;
    .

#TBD
<#dip_tbd> rdf:type ja:RDFDataset ;
     ja:defaultGraph <#infModel>  ;	 
	 tdb:fileMode "direct" ;
	 .

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

<#tdbGraph>  rdf:type tdb:GraphTDB ;
	#tdb2:location "C:\\etc\\fuseki/databases/dip" ;
	#tdb2:unionDefaultGraph true ;
	tdb:dataset <#tdbDataset> ;
	.
	
<#tdbDataset> rdf:type tdb:DatasetTDB ;	
	tdb:unionDefaultGraph true ;
	tdb:location "C:\\etc\\fuseki/databases/dip" ;
	.

Thanks for the help!!!!



On 2020/12/06 10:09:58, Andy Seaborne <an...@apache.org> wrote: 
> Please say what the error is and show the configuration you are trying.
> 
>      Andy
> 
> PS The config below has a lot of unnecessary items.
> 
> On 06/12/2020 01:18, Sushanth Vaddaram wrote:
> > I tried the following dataset for In-memory but when trying to add reasoner, the server does not start. Can some some one please provide the configuration we can use for in-memory dataset with a reasoner.
> > 
> > Config
> > =====
> > 
> > @prefix :      <http://base/#> .
> > @prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
> > @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> > @prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
> > @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
> > @prefix fuseki: <http://jena.apache.org/fuseki#> .
> > 
> > <http://jena.apache.org/2016/tdb#DatasetTDB>
> >          rdfs:subClassOf  ja:RDFDataset .
> > 
> > ja:DatasetTxnMem  rdfs:subClassOf  ja:RDFDataset .
> > 
> > tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> > 
> > :service1  a                          fuseki:Service ;
> >          fuseki:dataset                :dataset ;
> >          fuseki:name                   "dip10" ;
> >          fuseki:serviceQuery           "" , "query" , "sparql" ;
> >          fuseki:serviceReadGraphStore  "get" ;
> >          fuseki:serviceReadQuads       "" ;
> >          fuseki:serviceReadWriteGraphStore
> >                  "data" ;
> >          fuseki:serviceReadWriteQuads  "" ;
> >          fuseki:serviceUpdate          "update" , "" ;
> >          fuseki:serviceUpload          "upload" .
> > 
> > tdb:GraphTDB  rdfs:subClassOf  ja:Model .
> > 
> > <http://jena.apache.org/2016/tdb#GraphTDB2>
> >          rdfs:subClassOf  ja:Model .
> > 
> > ja:MemoryDataset  rdfs:subClassOf  ja:RDFDataset .
> > 
> > ja:RDFDatasetZero  rdfs:subClassOf  ja:RDFDataset .
> > 
> > <http://jena.apache.org/text#TextDataset>
> >          rdfs:subClassOf  ja:RDFDataset .
> > 
> > <http://jena.apache.org/2016/tdb#GraphTDB>
> >          rdfs:subClassOf  ja:Model .
> > 
> > ja:RDFDatasetOne  rdfs:subClassOf  ja:RDFDataset .
> > 
> > ja:RDFDatasetSink  rdfs:subClassOf  ja:RDFDataset .
> > 
> > :dataset  a     ja:DatasetTxnMem .
> > 
> > <http://jena.apache.org/2016/tdb#DatasetTDB2>
> >          rdfs:subClassOf  ja:RDFDataset .
> > 
> > 
> > On 2020/12/04 08:31:36, Andy Seaborne <an...@apache.org> wrote:
> >>
> >>
> >> On 04/12/2020 02:52, Sushanth Vaddaram wrote:
> >>> Thanks Dave.
> >>>
> >>> If we go with in-memory dataset, will I be loosing the data between jena restarts?
> >>
> >> Yes.
> >>
> >> You can write the data out to a file after computing and reload from
> >> that - or write the materialised data to second TDB database and work
> >> from that.
> >>
> >> The first part of the query could be rewritten - the first three triple
> >> patterns are the same in each branch:
> >>
> >> WHERE {
> >> ?datapointURI  rdf:type   dip:DataPoint  .
> >> ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >> ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>
> >> {
> >> ?datapointURI  rdf:type   ?datapointTYPE .
> >> } UNION {
> >>    ?datapointURI  rdfs:label   ?datapointLABEL .
> >> } UNION {
> >> ....
> >> }
> >>
> >> and it may help to reorder to put the SELECT DISTNCT first.
> >>
> >>       Andy
> >>
> >>>
> >>> Thanks,
> >>> Sushanth
> >>>
> >>> On 2020/12/03 19:13:58, Dave Reynolds <da...@gmail.com> wrote:
> >>>> Hi,
> >>>>
> >>>> If your data doesn't change then yes you can compute the results ahead
> >>>> of time. Set up your data and reasoner, write the whole resulting model
> >>>> out to a dump file. Then you can load that dump file into another TDB
> >>>> and serve it as a fuseki dataset with no reasoner configuration.
> >>>>
> >>>> That doesn't help if your data is continuously changing though.
> >>>>
> >>>> The other option would be to run in-memory instead of from TDB. Given
> >>>> the reasoners are intrinsically limited to data that fits in memory then
> >>>> would could switch to running in memory, reading the data in from files
> >>>> when fuseki starts up. That would mean start up is slow but the reasoner
> >>>> performance will be a little better.
> >>>>
> >>>> If neither of those options work or are open to you then I'm afraid it
> >>>> may simply be that the reasoner is not up to the job.
> >>>>
> >>>> Dave
> >>>>
> >>>> On 03/12/2020 17:47, Sushanth Vaddaram wrote:
> >>>>> We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.
> >>>>>
> >>>>> Query:
> >>>>>
> >>>>> PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#>
> >>>>> PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#>
> >>>>> PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#>
> >>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> >>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> >>>>> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> >>>>>
> >>>>> SELECT DISTINCT
> >>>>>      ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
> >>>>> WHERE
> >>>>> {
> >>>>>     {
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>>>     ?datapointURI  rdf:type   ?datapointTYPE .
> >>>>>     }
> >>>>> 	UNION
> >>>>>     {
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>>>     ?datapointURI  rdfs:label   ?datapointLABEL .
> >>>>>     }
> >>>>> 	UNION
> >>>>>     {
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>>>     ?datapointURI  dip:data_source_url   ?datapointDATAMOD .
> >>>>>     }
> >>>>> 	UNION
> >>>>>     {
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM .
> >>>>>     }
> >>>>> 	UNION
> >>>>>     {
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     }
> >>>>> 	UNION
> >>>>>     {
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>>>     ?datapointURI  dip:abstracts   ?datapointABSTPROP .
> >>>>>     }
> >>>>> {
> >>>>>
> >>>>>
> >>>>> SELECT DISTINCT
> >>>>>      ?datapointURI
> >>>>> WHERE
> >>>>> {
> >>>>>     {
> >>>>>     ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> .
> >>>>>     ?zoneURI  dip:has_scene_property   ?zonePROP .
> >>>>>     ?datapointURI  dip:abstracts   ?zonePROP .
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     }
> >>>>> 	UNION
> >>>>>     {
> >>>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI .
> >>>>>     ?deviceURI  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     }
> >>>>> 	UNION
> >>>>>     {
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI .
> >>>>>     ?deviceURI  dip:provides_info_object   ?datapointURI .
> >>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
> >>>>>     }
> >>>>> }
> >>>>>
> >>>>> }
> >>>>> }
> >>>>>
> >>>>>
> >>>>>
> >>>>> Configuration:
> >>>>> ==========
> >>>>> @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
> >>>>> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> >>>>>
> >>>>> [] rdf:type fuseki:Server ;
> >>>>>       fuseki:services (	
> >>>>>         <#dip>
> >>>>>       ) .
> >>>>>
> >>>>> # TDB
> >>>>> #[] ja:loadClass "org.apache.jena.tdb.TDB" .
> >>>>> #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> >>>>> #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> >>>>>
> >>>>> ## ---------------------------------------------------------------
> >>>>>
> >>>>> <#dip> rdf:type fuseki:Service ;
> >>>>>        # URI of the dataset -- http://host:port/dip
> >>>>>        fuseki:name                        "dip" ;
> >>>>>        fuseki:serviceQuery                "sparql" ;
> >>>>>        fuseki:serviceQuery                "query" ;
> >>>>>        fuseki:serviceUpdate               "update" ;
> >>>>>        fuseki:serviceUpload               "upload" ;
> >>>>>        fuseki:serviceReadWriteGraphStore  "data" ;
> >>>>>        fuseki:serviceReadGraphStore       "get" ;
> >>>>>        fuseki:dataset                     <#dip_tbd> ;
> >>>>>        .
> >>>>>
> >>>>> #TBD
> >>>>> <#dip_tbd> rdf:type ja:RDFDataset ;
> >>>>>         ja:defaultGraph <#infModel>  ;	
> >>>>> 	 tdb:fileMode "direct" ;
> >>>>> 	 .
> >>>>>
> >>>>> <#infModel>  a ja:InfModel ;
> >>>>>          ja:baseModel <#tdbGraph>;
> >>>>>          ja:reasoner
> >>>>>             [ja:reasonerURL
> >>>>>                 <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
> >>>>>
> >>>>> <#tdbGraph>  rdf:type tdb2:GraphTDB ;
> >>>>> 	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
> >>>>> 	tdb2:unionDefaultGraph true ;
> >>>>>
> >>>>> 	.
> >>>>>
> >>>>>
> >>>>> Thanks for the help!!!
> >>>>>
> >>>>
> >>
> 

Re: Jena Performance Issue with Reasoner

Posted by Andy Seaborne <an...@apache.org>.
Please say what the error is and show the configuration you are trying.

     Andy

PS The config below has a lot of unnecessary items.

On 06/12/2020 01:18, Sushanth Vaddaram wrote:
> I tried the following dataset for In-memory but when trying to add reasoner, the server does not start. Can some some one please provide the configuration we can use for in-memory dataset with a reasoner.
> 
> Config
> =====
> 
> @prefix :      <http://base/#> .
> @prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
> @prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
> @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
> @prefix fuseki: <http://jena.apache.org/fuseki#> .
> 
> <http://jena.apache.org/2016/tdb#DatasetTDB>
>          rdfs:subClassOf  ja:RDFDataset .
> 
> ja:DatasetTxnMem  rdfs:subClassOf  ja:RDFDataset .
> 
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> 
> :service1  a                          fuseki:Service ;
>          fuseki:dataset                :dataset ;
>          fuseki:name                   "dip10" ;
>          fuseki:serviceQuery           "" , "query" , "sparql" ;
>          fuseki:serviceReadGraphStore  "get" ;
>          fuseki:serviceReadQuads       "" ;
>          fuseki:serviceReadWriteGraphStore
>                  "data" ;
>          fuseki:serviceReadWriteQuads  "" ;
>          fuseki:serviceUpdate          "update" , "" ;
>          fuseki:serviceUpload          "upload" .
> 
> tdb:GraphTDB  rdfs:subClassOf  ja:Model .
> 
> <http://jena.apache.org/2016/tdb#GraphTDB2>
>          rdfs:subClassOf  ja:Model .
> 
> ja:MemoryDataset  rdfs:subClassOf  ja:RDFDataset .
> 
> ja:RDFDatasetZero  rdfs:subClassOf  ja:RDFDataset .
> 
> <http://jena.apache.org/text#TextDataset>
>          rdfs:subClassOf  ja:RDFDataset .
> 
> <http://jena.apache.org/2016/tdb#GraphTDB>
>          rdfs:subClassOf  ja:Model .
> 
> ja:RDFDatasetOne  rdfs:subClassOf  ja:RDFDataset .
> 
> ja:RDFDatasetSink  rdfs:subClassOf  ja:RDFDataset .
> 
> :dataset  a     ja:DatasetTxnMem .
> 
> <http://jena.apache.org/2016/tdb#DatasetTDB2>
>          rdfs:subClassOf  ja:RDFDataset .
> 
> 
> On 2020/12/04 08:31:36, Andy Seaborne <an...@apache.org> wrote:
>>
>>
>> On 04/12/2020 02:52, Sushanth Vaddaram wrote:
>>> Thanks Dave.
>>>
>>> If we go with in-memory dataset, will I be loosing the data between jena restarts?
>>
>> Yes.
>>
>> You can write the data out to a file after computing and reload from
>> that - or write the materialised data to second TDB database and work
>> from that.
>>
>> The first part of the query could be rewritten - the first three triple
>> patterns are the same in each branch:
>>
>> WHERE {
>> ?datapointURI  rdf:type   dip:DataPoint  .
>> ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>> ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>
>> {
>> ?datapointURI  rdf:type   ?datapointTYPE .
>> } UNION {
>>    ?datapointURI  rdfs:label   ?datapointLABEL .
>> } UNION {
>> ....
>> }
>>
>> and it may help to reorder to put the SELECT DISTNCT first.
>>
>>       Andy
>>
>>>
>>> Thanks,
>>> Sushanth
>>>
>>> On 2020/12/03 19:13:58, Dave Reynolds <da...@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> If your data doesn't change then yes you can compute the results ahead
>>>> of time. Set up your data and reasoner, write the whole resulting model
>>>> out to a dump file. Then you can load that dump file into another TDB
>>>> and serve it as a fuseki dataset with no reasoner configuration.
>>>>
>>>> That doesn't help if your data is continuously changing though.
>>>>
>>>> The other option would be to run in-memory instead of from TDB. Given
>>>> the reasoners are intrinsically limited to data that fits in memory then
>>>> would could switch to running in memory, reading the data in from files
>>>> when fuseki starts up. That would mean start up is slow but the reasoner
>>>> performance will be a little better.
>>>>
>>>> If neither of those options work or are open to you then I'm afraid it
>>>> may simply be that the reasoner is not up to the job.
>>>>
>>>> Dave
>>>>
>>>> On 03/12/2020 17:47, Sushanth Vaddaram wrote:
>>>>> We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.
>>>>>
>>>>> Query:
>>>>>
>>>>> PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#>
>>>>> PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#>
>>>>> PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#>
>>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>>> PREFIX owl: <http://www.w3.org/2002/07/owl#>
>>>>>
>>>>> SELECT DISTINCT
>>>>>      ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
>>>>> WHERE
>>>>> {
>>>>>     {
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>>>     ?datapointURI  rdf:type   ?datapointTYPE .
>>>>>     }
>>>>> 	UNION
>>>>>     {
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>>>     ?datapointURI  rdfs:label   ?datapointLABEL .
>>>>>     }
>>>>> 	UNION
>>>>>     {
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>>>     ?datapointURI  dip:data_source_url   ?datapointDATAMOD .
>>>>>     }
>>>>> 	UNION
>>>>>     {
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM .
>>>>>     }
>>>>> 	UNION
>>>>>     {
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     }
>>>>> 	UNION
>>>>>     {
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>>>     ?datapointURI  dip:abstracts   ?datapointABSTPROP .
>>>>>     }
>>>>> {
>>>>>
>>>>>
>>>>> SELECT DISTINCT
>>>>>      ?datapointURI
>>>>> WHERE
>>>>> {
>>>>>     {
>>>>>     ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> .
>>>>>     ?zoneURI  dip:has_scene_property   ?zonePROP .
>>>>>     ?datapointURI  dip:abstracts   ?zonePROP .
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     }
>>>>> 	UNION
>>>>>     {
>>>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI .
>>>>>     ?deviceURI  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     }
>>>>> 	UNION
>>>>>     {
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI .
>>>>>     ?deviceURI  dip:provides_info_object   ?datapointURI .
>>>>>     ?datapointURI  rdf:type   dip:DataPoint  .
>>>>>     }
>>>>> }
>>>>>
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> Configuration:
>>>>> ==========
>>>>> @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
>>>>> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
>>>>>
>>>>> [] rdf:type fuseki:Server ;
>>>>>       fuseki:services (	
>>>>>         <#dip>
>>>>>       ) .
>>>>>
>>>>> # TDB
>>>>> #[] ja:loadClass "org.apache.jena.tdb.TDB" .
>>>>> #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
>>>>> #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>>>>>
>>>>> ## ---------------------------------------------------------------
>>>>>
>>>>> <#dip> rdf:type fuseki:Service ;
>>>>>        # URI of the dataset -- http://host:port/dip
>>>>>        fuseki:name                        "dip" ;
>>>>>        fuseki:serviceQuery                "sparql" ;
>>>>>        fuseki:serviceQuery                "query" ;
>>>>>        fuseki:serviceUpdate               "update" ;
>>>>>        fuseki:serviceUpload               "upload" ;
>>>>>        fuseki:serviceReadWriteGraphStore  "data" ;
>>>>>        fuseki:serviceReadGraphStore       "get" ;
>>>>>        fuseki:dataset                     <#dip_tbd> ;
>>>>>        .
>>>>>
>>>>> #TBD
>>>>> <#dip_tbd> rdf:type ja:RDFDataset ;
>>>>>         ja:defaultGraph <#infModel>  ;	
>>>>> 	 tdb:fileMode "direct" ;
>>>>> 	 .
>>>>>
>>>>> <#infModel>  a ja:InfModel ;
>>>>>          ja:baseModel <#tdbGraph>;
>>>>>          ja:reasoner
>>>>>             [ja:reasonerURL
>>>>>                 <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
>>>>>
>>>>> <#tdbGraph>  rdf:type tdb2:GraphTDB ;
>>>>> 	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
>>>>> 	tdb2:unionDefaultGraph true ;
>>>>>
>>>>> 	.
>>>>>
>>>>>
>>>>> Thanks for the help!!!
>>>>>
>>>>
>>

Re: Jena Performance Issue with Reasoner

Posted by Sushanth Vaddaram <su...@gmail.com>.
I tried the following dataset for In-memory but when trying to add reasoner, the server does not start. Can some some one please provide the configuration we can use for in-memory dataset with a reasoner.

Config
=====

@prefix :      <http://base/#> .
@prefix tdb:   <http://jena.hpl.hp.com/2008/tdb#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ja:    <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .

<http://jena.apache.org/2016/tdb#DatasetTDB>
        rdfs:subClassOf  ja:RDFDataset .

ja:DatasetTxnMem  rdfs:subClassOf  ja:RDFDataset .

tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .

:service1  a                          fuseki:Service ;
        fuseki:dataset                :dataset ;
        fuseki:name                   "dip10" ;
        fuseki:serviceQuery           "" , "query" , "sparql" ;
        fuseki:serviceReadGraphStore  "get" ;
        fuseki:serviceReadQuads       "" ;
        fuseki:serviceReadWriteGraphStore
                "data" ;
        fuseki:serviceReadWriteQuads  "" ;
        fuseki:serviceUpdate          "update" , "" ;
        fuseki:serviceUpload          "upload" .

tdb:GraphTDB  rdfs:subClassOf  ja:Model .

<http://jena.apache.org/2016/tdb#GraphTDB2>
        rdfs:subClassOf  ja:Model .

ja:MemoryDataset  rdfs:subClassOf  ja:RDFDataset .

ja:RDFDatasetZero  rdfs:subClassOf  ja:RDFDataset .

<http://jena.apache.org/text#TextDataset>
        rdfs:subClassOf  ja:RDFDataset .

<http://jena.apache.org/2016/tdb#GraphTDB>
        rdfs:subClassOf  ja:Model .

ja:RDFDatasetOne  rdfs:subClassOf  ja:RDFDataset .

ja:RDFDatasetSink  rdfs:subClassOf  ja:RDFDataset .

:dataset  a     ja:DatasetTxnMem .

<http://jena.apache.org/2016/tdb#DatasetTDB2>
        rdfs:subClassOf  ja:RDFDataset .


On 2020/12/04 08:31:36, Andy Seaborne <an...@apache.org> wrote: 
> 
> 
> On 04/12/2020 02:52, Sushanth Vaddaram wrote:
> > Thanks Dave.
> > 
> > If we go with in-memory dataset, will I be loosing the data between jena restarts?
> 
> Yes.
> 
> You can write the data out to a file after computing and reload from 
> that - or write the materialised data to second TDB database and work 
> from that.
> 
> The first part of the query could be rewritten - the first three triple 
> patterns are the same in each branch:
> 
> WHERE {
> ?datapointURI  rdf:type   dip:DataPoint  .
> ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> 
> {
> ?datapointURI  rdf:type   ?datapointTYPE .
> } UNION {
>   ?datapointURI  rdfs:label   ?datapointLABEL .
> } UNION {
> ....
> }
> 
> and it may help to reorder to put the SELECT DISTNCT first.
> 
>      Andy
> 
> > 
> > Thanks,
> > Sushanth
> > 
> > On 2020/12/03 19:13:58, Dave Reynolds <da...@gmail.com> wrote:
> >> Hi,
> >>
> >> If your data doesn't change then yes you can compute the results ahead
> >> of time. Set up your data and reasoner, write the whole resulting model
> >> out to a dump file. Then you can load that dump file into another TDB
> >> and serve it as a fuseki dataset with no reasoner configuration.
> >>
> >> That doesn't help if your data is continuously changing though.
> >>
> >> The other option would be to run in-memory instead of from TDB. Given
> >> the reasoners are intrinsically limited to data that fits in memory then
> >> would could switch to running in memory, reading the data in from files
> >> when fuseki starts up. That would mean start up is slow but the reasoner
> >> performance will be a little better.
> >>
> >> If neither of those options work or are open to you then I'm afraid it
> >> may simply be that the reasoner is not up to the job.
> >>
> >> Dave
> >>
> >> On 03/12/2020 17:47, Sushanth Vaddaram wrote:
> >>> We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.
> >>>
> >>> Query:
> >>>
> >>> PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#>
> >>> PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#>
> >>> PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#>
> >>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> >>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> >>> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> >>>
> >>> SELECT DISTINCT
> >>>     ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
> >>> WHERE
> >>> {
> >>>    {
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>    ?datapointURI  rdf:type   ?datapointTYPE .
> >>>    }
> >>> 	UNION
> >>>    {
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>    ?datapointURI  rdfs:label   ?datapointLABEL .
> >>>    }
> >>> 	UNION
> >>>    {
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>    ?datapointURI  dip:data_source_url   ?datapointDATAMOD .
> >>>    }
> >>> 	UNION
> >>>    {
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM .
> >>>    }
> >>> 	UNION
> >>>    {
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    }
> >>> 	UNION
> >>>    {
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>>    ?datapointURI  dip:abstracts   ?datapointABSTPROP .
> >>>    }
> >>> {
> >>>
> >>>
> >>> SELECT DISTINCT
> >>>     ?datapointURI
> >>> WHERE
> >>> {
> >>>    {
> >>>    ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> .
> >>>    ?zoneURI  dip:has_scene_property   ?zonePROP .
> >>>    ?datapointURI  dip:abstracts   ?zonePROP .
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    }
> >>> 	UNION
> >>>    {
> >>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI .
> >>>    ?deviceURI  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    }
> >>> 	UNION
> >>>    {
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI .
> >>>    ?deviceURI  dip:provides_info_object   ?datapointURI .
> >>>    ?datapointURI  rdf:type   dip:DataPoint  .
> >>>    }
> >>> }
> >>>
> >>> }
> >>> }
> >>>
> >>>
> >>>
> >>> Configuration:
> >>> ==========
> >>> @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
> >>> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> >>>
> >>> [] rdf:type fuseki:Server ;
> >>>      fuseki:services (	
> >>>        <#dip>
> >>>      ) .
> >>>
> >>> # TDB
> >>> #[] ja:loadClass "org.apache.jena.tdb.TDB" .
> >>> #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> >>> #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> >>>
> >>> ## ---------------------------------------------------------------
> >>>
> >>> <#dip> rdf:type fuseki:Service ;
> >>>       # URI of the dataset -- http://host:port/dip
> >>>       fuseki:name                        "dip" ;
> >>>       fuseki:serviceQuery                "sparql" ;
> >>>       fuseki:serviceQuery                "query" ;
> >>>       fuseki:serviceUpdate               "update" ;
> >>>       fuseki:serviceUpload               "upload" ;
> >>>       fuseki:serviceReadWriteGraphStore  "data" ;
> >>>       fuseki:serviceReadGraphStore       "get" ;
> >>>       fuseki:dataset                     <#dip_tbd> ;
> >>>       .
> >>>
> >>> #TBD
> >>> <#dip_tbd> rdf:type ja:RDFDataset ;
> >>>        ja:defaultGraph <#infModel>  ;	
> >>> 	 tdb:fileMode "direct" ;
> >>> 	 .
> >>>
> >>> <#infModel>  a ja:InfModel ;
> >>>         ja:baseModel <#tdbGraph>;
> >>>         ja:reasoner
> >>>            [ja:reasonerURL
> >>>                <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
> >>>
> >>> <#tdbGraph>  rdf:type tdb2:GraphTDB ;
> >>> 	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
> >>> 	tdb2:unionDefaultGraph true ;
> >>>
> >>> 	.
> >>>
> >>>
> >>> Thanks for the help!!!
> >>>
> >>
> 

Re: Jena Performance Issue with Reasoner

Posted by Andy Seaborne <an...@apache.org>.

On 04/12/2020 02:52, Sushanth Vaddaram wrote:
> Thanks Dave.
> 
> If we go with in-memory dataset, will I be loosing the data between jena restarts?

Yes.

You can write the data out to a file after computing and reload from 
that - or write the materialised data to second TDB database and work 
from that.

The first part of the query could be rewritten - the first three triple 
patterns are the same in each branch:

WHERE {
?datapointURI  rdf:type   dip:DataPoint  .
?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .

{
?datapointURI  rdf:type   ?datapointTYPE .
} UNION {
  ?datapointURI  rdfs:label   ?datapointLABEL .
} UNION {
....
}

and it may help to reorder to put the SELECT DISTNCT first.

     Andy

> 
> Thanks,
> Sushanth
> 
> On 2020/12/03 19:13:58, Dave Reynolds <da...@gmail.com> wrote:
>> Hi,
>>
>> If your data doesn't change then yes you can compute the results ahead
>> of time. Set up your data and reasoner, write the whole resulting model
>> out to a dump file. Then you can load that dump file into another TDB
>> and serve it as a fuseki dataset with no reasoner configuration.
>>
>> That doesn't help if your data is continuously changing though.
>>
>> The other option would be to run in-memory instead of from TDB. Given
>> the reasoners are intrinsically limited to data that fits in memory then
>> would could switch to running in memory, reading the data in from files
>> when fuseki starts up. That would mean start up is slow but the reasoner
>> performance will be a little better.
>>
>> If neither of those options work or are open to you then I'm afraid it
>> may simply be that the reasoner is not up to the job.
>>
>> Dave
>>
>> On 03/12/2020 17:47, Sushanth Vaddaram wrote:
>>> We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.
>>>
>>> Query:
>>>
>>> PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#>
>>> PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#>
>>> PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#>
>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>> PREFIX owl: <http://www.w3.org/2002/07/owl#>
>>>
>>> SELECT DISTINCT
>>>     ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
>>> WHERE
>>> {
>>>    {
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>    ?datapointURI  rdf:type   ?datapointTYPE .
>>>    }
>>> 	UNION
>>>    {
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>    ?datapointURI  rdfs:label   ?datapointLABEL .
>>>    }
>>> 	UNION
>>>    {
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>    ?datapointURI  dip:data_source_url   ?datapointDATAMOD .
>>>    }
>>> 	UNION
>>>    {
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM .
>>>    }
>>> 	UNION
>>>    {
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    }
>>> 	UNION
>>>    {
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>>    ?datapointURI  dip:abstracts   ?datapointABSTPROP .
>>>    }
>>> {
>>>
>>>
>>> SELECT DISTINCT
>>>     ?datapointURI
>>> WHERE
>>> {
>>>    {
>>>    ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> .
>>>    ?zoneURI  dip:has_scene_property   ?zonePROP .
>>>    ?datapointURI  dip:abstracts   ?zonePROP .
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    }
>>> 	UNION
>>>    {
>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI .
>>>    ?deviceURI  dip:provides_info_object   ?datapointURI .
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    }
>>> 	UNION
>>>    {
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>>>    ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>>> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI .
>>>    ?deviceURI  dip:provides_info_object   ?datapointURI .
>>>    ?datapointURI  rdf:type   dip:DataPoint  .
>>>    }
>>> }
>>>
>>> }
>>> }
>>>
>>>
>>>
>>> Configuration:
>>> ==========
>>> @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
>>> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
>>>
>>> [] rdf:type fuseki:Server ;
>>>      fuseki:services (	
>>>        <#dip>
>>>      ) .
>>>
>>> # TDB
>>> #[] ja:loadClass "org.apache.jena.tdb.TDB" .
>>> #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
>>> #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>>>
>>> ## ---------------------------------------------------------------
>>>
>>> <#dip> rdf:type fuseki:Service ;
>>>       # URI of the dataset -- http://host:port/dip
>>>       fuseki:name                        "dip" ;
>>>       fuseki:serviceQuery                "sparql" ;
>>>       fuseki:serviceQuery                "query" ;
>>>       fuseki:serviceUpdate               "update" ;
>>>       fuseki:serviceUpload               "upload" ;
>>>       fuseki:serviceReadWriteGraphStore  "data" ;
>>>       fuseki:serviceReadGraphStore       "get" ;
>>>       fuseki:dataset                     <#dip_tbd> ;
>>>       .
>>>
>>> #TBD
>>> <#dip_tbd> rdf:type ja:RDFDataset ;
>>>        ja:defaultGraph <#infModel>  ;	
>>> 	 tdb:fileMode "direct" ;
>>> 	 .
>>>
>>> <#infModel>  a ja:InfModel ;
>>>         ja:baseModel <#tdbGraph>;
>>>         ja:reasoner
>>>            [ja:reasonerURL
>>>                <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
>>>
>>> <#tdbGraph>  rdf:type tdb2:GraphTDB ;
>>> 	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
>>> 	tdb2:unionDefaultGraph true ;
>>>
>>> 	.
>>>
>>>
>>> Thanks for the help!!!
>>>
>>

Re: Jena Performance Issue with Reasoner

Posted by Sushanth Vaddaram <su...@gmail.com>.
Thanks Dave.

If we go with in-memory dataset, will I be loosing the data between jena restarts?

Thanks,
Sushanth

On 2020/12/03 19:13:58, Dave Reynolds <da...@gmail.com> wrote: 
> Hi,
> 
> If your data doesn't change then yes you can compute the results ahead 
> of time. Set up your data and reasoner, write the whole resulting model 
> out to a dump file. Then you can load that dump file into another TDB 
> and serve it as a fuseki dataset with no reasoner configuration.
> 
> That doesn't help if your data is continuously changing though.
> 
> The other option would be to run in-memory instead of from TDB. Given 
> the reasoners are intrinsically limited to data that fits in memory then 
> would could switch to running in memory, reading the data in from files 
> when fuseki starts up. That would mean start up is slow but the reasoner 
> performance will be a little better.
> 
> If neither of those options work or are open to you then I'm afraid it 
> may simply be that the reasoner is not up to the job.
> 
> Dave
> 
> On 03/12/2020 17:47, Sushanth Vaddaram wrote:
> > We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.
> > 
> > Query:
> > 
> > PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#>
> > PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#>
> > PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#>
> > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> > PREFIX owl: <http://www.w3.org/2002/07/owl#>
> > 
> > SELECT DISTINCT
> >    ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
> > WHERE
> > {
> >   {
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >   ?datapointURI  rdf:type   ?datapointTYPE .
> >   }
> > 	UNION
> >   {
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >   ?datapointURI  rdfs:label   ?datapointLABEL .
> >   }
> > 	UNION
> >   {
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >   ?datapointURI  dip:data_source_url   ?datapointDATAMOD .
> >   }
> > 	UNION
> >   {
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM .
> >   }
> > 	UNION
> >   {
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   }
> > 	UNION
> >   {
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> >   ?datapointURI  dip:abstracts   ?datapointABSTPROP .
> >   }
> > {
> > 
> > 
> > SELECT DISTINCT
> >    ?datapointURI
> > WHERE
> > {
> >   {
> >   ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> .
> >   ?zoneURI  dip:has_scene_property   ?zonePROP .
> >   ?datapointURI  dip:abstracts   ?zonePROP .
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   }
> > 	UNION
> >   {
> > <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI .
> >   ?deviceURI  dip:provides_info_object   ?datapointURI .
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   }
> > 	UNION
> >   {
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
> >   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> > <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI .
> >   ?deviceURI  dip:provides_info_object   ?datapointURI .
> >   ?datapointURI  rdf:type   dip:DataPoint  .
> >   }
> > }
> > 
> > }
> > }
> > 
> > 
> > 
> > Configuration:
> > ==========
> > @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
> > @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> > 
> > [] rdf:type fuseki:Server ;
> >     fuseki:services (	
> >       <#dip>
> >     ) .
> > 
> > # TDB
> > #[] ja:loadClass "org.apache.jena.tdb.TDB" .
> > #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> > #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> > 
> > ## ---------------------------------------------------------------
> > 
> > <#dip> rdf:type fuseki:Service ;
> >      # URI of the dataset -- http://host:port/dip
> >      fuseki:name                        "dip" ;
> >      fuseki:serviceQuery                "sparql" ;
> >      fuseki:serviceQuery                "query" ;
> >      fuseki:serviceUpdate               "update" ;
> >      fuseki:serviceUpload               "upload" ;
> >      fuseki:serviceReadWriteGraphStore  "data" ;
> >      fuseki:serviceReadGraphStore       "get" ;
> >      fuseki:dataset                     <#dip_tbd> ;
> >      .
> > 
> > #TBD
> > <#dip_tbd> rdf:type ja:RDFDataset ;
> >       ja:defaultGraph <#infModel>  ;	
> > 	 tdb:fileMode "direct" ;
> > 	 .
> > 
> > <#infModel>  a ja:InfModel ;
> >        ja:baseModel <#tdbGraph>;
> >        ja:reasoner
> >           [ja:reasonerURL
> >               <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
> > 
> > <#tdbGraph>  rdf:type tdb2:GraphTDB ;
> > 	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
> > 	tdb2:unionDefaultGraph true ;
> > 
> > 	.
> > 
> > 
> > Thanks for the help!!!
> > 
> 

Re: Jena Performance Issue with Reasoner

Posted by Dave Reynolds <da...@gmail.com>.
Hi,

If your data doesn't change then yes you can compute the results ahead 
of time. Set up your data and reasoner, write the whole resulting model 
out to a dump file. Then you can load that dump file into another TDB 
and serve it as a fuseki dataset with no reasoner configuration.

That doesn't help if your data is continuously changing though.

The other option would be to run in-memory instead of from TDB. Given 
the reasoners are intrinsically limited to data that fits in memory then 
would could switch to running in memory, reading the data in from files 
when fuseki starts up. That would mean start up is slow but the reasoner 
performance will be a little better.

If neither of those options work or are open to you then I'm afraid it 
may simply be that the reasoner is not up to the job.

Dave

On 03/12/2020 17:47, Sushanth Vaddaram wrote:
> We have 6 lakh statements and when trying to hit the  query with the configuration below, it is almost taking 90 secs to load the results. Is there anything I can do to improve the performance. Also is there any way inferencing can be done during loading of the statements rather than runtime as I was getting the result in 2 seconds without the reasoner in the configuration.
> 
> Query:
> 
> PREFIX dip:<http://sce.ccs.utc.com/dip/reference-ontology#>
> PREFIX map-onto:<http://sce.ccs.utc.com/dip/mapping-ontology#>
> PREFIX auth:<http://sce.ccs.utc.com/dip/semantics/authorization#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> 
> SELECT DISTINCT
>    ?datapointURI  ?datapointTYPE  ?datapointLABEL  ?datapointSYSTEM  ?datapointPROVIDER  ?datapointDATAMOD  ?datapointABSTPROP
> WHERE
> {
>   {
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>   ?datapointURI  rdf:type   ?datapointTYPE .
>   }
> 	UNION
>   {
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>   ?datapointURI  rdfs:label   ?datapointLABEL .
>   }
> 	UNION
>   {
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>   ?datapointURI  dip:data_source_url   ?datapointDATAMOD .
>   }
> 	UNION
>   {
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system   ?datapointSYSTEM .
>   }
> 	UNION
>   {
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   }
> 	UNION
>   {
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
>   ?datapointURI  dip:abstracts   ?datapointABSTPROP .
>   }
> {
> 
> 
> SELECT DISTINCT
>    ?datapointURI
> WHERE
> {
>   {
>   ?zoneURI  dip:covers  <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135> .
>   ?zoneURI  dip:has_scene_property   ?zonePROP .
>   ?datapointURI  dip:abstracts   ?zonePROP .
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   }
> 	UNION
>   {
> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:spatial_containment   ?deviceURI .
>   ?deviceURI  dip:provides_info_object   ?datapointURI .
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   }
> 	UNION
>   {
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   ?datapointPROVIDER  dip:provides_info_object   ?datapointURI .
>   ?datapointPROVIDER  dip:in_system  <http://dip.bis.utc.com/7#bacnet_7> .
> <http://test.dip.ales/spacetest#03d78792bb3eb3086b9e4135>  dip:contains_hardware / dip:contains_hardware_device   ?deviceURI .
>   ?deviceURI  dip:provides_info_object   ?datapointURI .
>   ?datapointURI  rdf:type   dip:DataPoint  .
>   }
> }
> 
> }
> }
> 
> 
> 
> Configuration:
> ==========
> @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 tdb2:  <http://jena.apache.org/2016/tdb#> .
> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> 
> [] rdf:type fuseki:Server ;
>     fuseki:services (	
>       <#dip>
>     ) .
> 
> # TDB
> #[] ja:loadClass "org.apache.jena.tdb.TDB" .
> #tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> #tdb:GraphTDB    rdfs:subClassOf  ja:Model .
> 
> ## ---------------------------------------------------------------
> 
> <#dip> rdf:type fuseki:Service ;
>      # URI of the dataset -- http://host:port/dip
>      fuseki:name                        "dip" ;
>      fuseki:serviceQuery                "sparql" ;
>      fuseki:serviceQuery                "query" ;
>      fuseki:serviceUpdate               "update" ;
>      fuseki:serviceUpload               "upload" ;
>      fuseki:serviceReadWriteGraphStore  "data" ;
>      fuseki:serviceReadGraphStore       "get" ;
>      fuseki:dataset                     <#dip_tbd> ;
>      .
> 
> #TBD
> <#dip_tbd> rdf:type ja:RDFDataset ;
>       ja:defaultGraph <#infModel>  ;	
> 	 tdb:fileMode "direct" ;
> 	 .
> 
> <#infModel>  a ja:InfModel ;
>        ja:baseModel <#tdbGraph>;
>        ja:reasoner
>           [ja:reasonerURL
>               <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner>].
> 
> <#tdbGraph>  rdf:type tdb2:GraphTDB ;
> 	tdb2:location "C:\\etc\\fuseki/databases/dip5" ;
> 	tdb2:unionDefaultGraph true ;
> 
> 	.
> 
> 
> Thanks for the help!!!
>