0

我正在使用GraphDB来存储我的三元组,并且需要在 GraphDB 上堆叠SpinSail组件以支持Spin 规则以及GraphDB默认支持的所有其他功能。

到目前为止,我已经设法在支持Spin Rules的远程服务器上创建了一个SailRepository(下面有更多详细信息),但它似乎只支持Spin ,并且不支持GraphDB支持的其他功能(例如,查看 Graph、通过文件添加三元组、搜索ETC。)

创建存储库后,配置文件如下所示:

@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"
        ]
    ] .

虽然一个普通的配置文件(例如,如果有人通过工作台创建一个存储库)看起来像下面这样:

@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" .

以下代码用于创建存储库。

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);

创建此存储库后,我可以通过SPARQL部分将以下规则插入其中(通过使用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 . }"""
] . }

然后类似地添加以下语句:

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

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

之后通过运行以下查询:

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

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

我能够确认 Spin 规则已成功执行。

所以我的问题是

有没有办法创建一个支持 GraphDB 的所有功能的远程存储库,然后在其上堆叠 SpinSail 组件?

4

1 回答 1

2

目前 GraphDB(8.10.0 版)不支持 SpinSail。此类选项正在考虑用于下一个 GraphDB 版本之一。

于 2019-06-11T08:11:32.500 回答