如何以事务方式持久保存耶拿数据?

时间:2019-01-20 13:24:49

标签: python jena fuseki

我将jena与fuseki一起用作我的sparql服务器,并使用python在sparql端点上执行HTTP请求以进行插入/更新。我需要有关如何使该过程“进行交易”的建议(我进行了搜索,但没有完全掌握这个概念)。

fuseki服务的配置如下,它指定目录tdb /下的数据集。该服务可以正常运行一段时间。然后有一天,我在python项目中发现日志,该日志显示查询fuseki端点失败。同时,Fuseki服务报告

  

org.apache.jena.dboe.DBOpEnvException:未知的块类型为0

用于各种请求。我的网络搜索结果表明,可能的原因是“可能的原因是您过去以非事务方式使用并且没有一次将更改刷新到磁盘上,或者应用程序崩溃了”。

相关网页为:

http://mail-archives.apache.org/mod_mbox/jena-users/201504.mbox/ <5541034B.3000304@gmail.com>

http://mail-archives.apache.org/mod_mbox/jena-users/201603.mbox/%3C56F4412C.8010002@apache.org%3E

# Service Configuration

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

<#serviceKgService>   a           fuseki:Service ;
fuseki:name                       "my_project" ;
fuseki:dataset                    <#dataset> ;
fuseki:serviceQuery               "query" , "sparql" ;
fuseki:serviceReadGraphStore      "get" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceUpdate              "update" ;
fuseki:serviceUpload              "upload" .

<#dataset> rdf:type ja:RDFDataset ;
ja:defaultGraph <#model_inf> .

<#model_inf> a ja:InfModel ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ; 
ja:rulesFrom <file:my_rules.ttl> ;
].

<#tdbGraph> rdf:type tdb2:GraphTDB ;
tdb2:dataset <#tdbDataset> .

<#tdbDataset> rdf:type tdb2:DatasetTDB ;
tdb2:location "tdb" .

[] rdf:type fuseki:Server ;

# Rules
@prefix : <http://kg.example.com/kg_root#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

[transitiveRule: (?p :subLevelOf ?m), (?m :subLevelOf ?q) -> (?p :subLevelOf ?q)]


# Last Queries: I did some replacement, but the key points
# are 1. the first object value is a length-2 chineses string
# 2. the seconds object value is a length-50 english string
select distinct ?x where {
?x <http://kg.example.com/prop/direct/example_prop1> '示例'.
?x <http://kg.example.com/prop/direct/example_prop2> 'xxxxxxxx.xxx.xxxxxx.xxxxxxxxxxxxx_xxxxxxxx_xxxx_xx'.
}

# Error

[2019-01-20 15:51:17] Fuseki     WARN  [5] RC = 500 : No known block type for 0
org.apache.jena.dboe.DBOpEnvException: No known block type for 0
at
org.apache.jena.dboe.base.block.BlockType.extract(BlockType.java:66)

0 个答案:

没有答案