Search code examples
graphdbrdf4j

How to stack SpinSail on top of GraphDB remote repository


I am using GraphDB to store my triples and need to stack SpinSail component upon the GraphDB to support Spin Rules along with all the rest of the features that GraphDB supports by default.

So far I have managed to create a SailRepository on the remote server supporting Spin Rules (more details below) but it seems that it only supports Spin and none of the other features that GraphDB supports (e.g. reviewing the Graph, adding triples through files, searching etc.)

The configuration file, once the repository is created, looks like below:

@prefix ms: <http://www.openrdf.org/config/sail/memory#> .
@prefix rep: <http://www.openrdf.org/config/repository#> .
@prefix sail: <http://www.openrdf.org/config/sail#> .
@prefix sr: <http://www.openrdf.org/config/repository/sail#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<#Test1> a rep:Repository;
  rep:repositoryID "Test1";
  rep:repositoryImpl [
      rep:repositoryType "openrdf:SailRepository";
      sr:sailImpl [
          sail:delegate [
              sail:sailType "openrdf:MemoryStore";
              ms:persist true
            ];
          sail:sailType "openrdf:SpinSail"
        ]
    ] .

Although a normal configuration file (i.e. if someone would create a repository through the workbench) would look like the one below:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rep: <http://www.openrdf.org/config/repository#> .
@prefix sail: <http://www.openrdf.org/config/sail#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<#Test> a rep:Repository;
  rep:repositoryID "Test";
  rep:repositoryImpl [
      rep:repositoryType "graphdb:FreeSailRepository";
      <http://www.openrdf.org/config/repository/sail#sailImpl> [
          <http://www.ontotext.com/trree/owlim#base-URL> "http://example.org/owlim#";
          <http://www.ontotext.com/trree/owlim#check-for-inconsistencies> "false";
          <http://www.ontotext.com/trree/owlim#defaultNS> "";
          <http://www.ontotext.com/trree/owlim#disable-sameAs> "false";
          <http://www.ontotext.com/trree/owlim#enable-context-index> "false";
          <http://www.ontotext.com/trree/owlim#enable-literal-index> "true";
          <http://www.ontotext.com/trree/owlim#enablePredicateList> "true";
          <http://www.ontotext.com/trree/owlim#entity-id-size> "32";
          <http://www.ontotext.com/trree/owlim#entity-index-size> "10000000";
          <http://www.ontotext.com/trree/owlim#imports> "";
          <http://www.ontotext.com/trree/owlim#in-memory-literal-properties> "true";
          <http://www.ontotext.com/trree/owlim#query-limit-results> "0";
          <http://www.ontotext.com/trree/owlim#query-timeout> "0";
          <http://www.ontotext.com/trree/owlim#read-only> "false";
          <http://www.ontotext.com/trree/owlim#repository-type> "file-repository";
          <http://www.ontotext.com/trree/owlim#ruleset> "owl2-rl-optimized";
          <http://www.ontotext.com/trree/owlim#storage-folder> "storage";
          <http://www.ontotext.com/trree/owlim#throw-QueryEvaluationException-on-timeout> "false";
          sail:sailType "graphdb:FreeSail"
        ]
    ];
  rdfs:label "Test" .

The following code was used to create the repository.

RemoteRepositoryManager manager = new RemoteRepositoryManager("http://localhost:7200");
        manager.init();

        String repositoryId = "Test1";

        // create a configuration for the SAIL stack
        boolean persist = true;

        // create a configuration for the SAIL stack
        SailImplConfig spinSailConfig = new MemoryStoreConfig(persist);

        spinSailConfig = new SpinSailConfig(spinSailConfig);

        RepositoryImplConfig repositoryTypeSpec = new SailRepositoryConfig(spinSailConfig);

        // create a configuration for the repository implementation
        // RepositoryImplConfig repositoryTypeSpec = new SailRepositoryConfig(backendConfig);

        RepositoryConfig repConfig = new RepositoryConfig(repositoryId, repositoryTypeSpec);
        manager.addRepositoryConfig(repConfig);

Once I created this repository I was able to insert the following rule into it through the SPARQL section (by using INSERT DATA):

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sp: <http://spinrdf.org/sp#>
PREFIX spin: <http://spinrdf.org/spin#>
PREFIX ex: <http://example.org/>

INSERT DATA {
ex:Person a rdfs:Class ;
    spin:rule [
        a sp:Construct ;
    sp:text """PREFIX ex: <http://example.org/>
               CONSTRUCT { ?this ex:childOf ?parent . }
               WHERE { ?parent ex:parentOf ?this . }"""
] . }

and then similarly add the following statements:

PREFIX ex: <http://example.org/>

INSERT DATA {
ex:John a ex:Father ;
        ex:parentOf ex:Lucy .
ex:Lucy a ex:Person .
}

After that by running the following query:

PREFIX ex: <http://example.org/>

SELECT ?child WHERE { ?child ex:childOf ?parent }

I was able to confirm that the Spin rule was executed successfully.

So my question is:

Is there a way to create a remote repository supporting all the features of GraphDB and then stack upon it the SpinSail component?


Solution

  • As of the moment GraphDB (version 8.10.0) does not support SpinSail. Such option is under consideration for one of the next GraphDB releases.