如何事务性地持久化jena数据

2024-05-10 12:15:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用jena和fuseki作为sparql服务器,并使用python对sparql端点执行HTTP请求以插入/更新。我需要关于如何使流程“事务化”的建议(我搜索了一下,但没有完全掌握这个概念)。你知道吗

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

org.apache.jena.dboe.DBOpEnvException: No known block type for 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)

Tags: orgcomhttpprefixapachewwwtypeservice