“超时/查询挂起";从耶拿(Jena)对DBpedia执行SPARQL查询时 [英] "Timeout/query hangs" while executing SPARQL query to DBpedia from Jena

查看:83
本文介绍了“超时/查询挂起";从耶拿(Jena)对DBpedia执行SPARQL查询时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用Jena对dbpedia.org执行SPARQL查询.

I am having trouble executing SPARQL queries against dbpedia.org using Jena.

查询的形式为:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
PREFIX p: <http://dbpedia.org/property/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
SELECT ?album ?name ?dateofrelease 
WHERE { 
?album p:artist <http://dbpedia.org/resource/SomeArtist> . 
?album rdf:type <http://dbpedia.org/ontology/Album> . 
?album rdf:type <http://schema.org/MusicAlbum> . 
?album p:name ?name . 
?album <http://dbpedia.org/ontology/releaseDate> ?dateofrelease . 
FILTER(xsd:dateTime(?dateofrelease) >= '2009-01-01T00:00:00Z'^^xsd:dateTime) 
} LIMIT 5 

其中 http://www.dbpedia.org/resource/SomeArtist 是有效的艺术家URI,例如 http://dbpedia.org/resource/Wilco ,并在发送前正确进行URL编码.

where http://www.dbpedia.org/resource/SomeArtist is a valid artist URI, e.g. http://dbpedia.org/resource/Wilco, and URL-encoded properly before sent.

使用以下标准代码执行查询:

The queries are executed with the following standard code:

Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
ResultSet results = queryExecution.execSelect();

该程序以相同的形式执行大约30个查询,但是其中一些在"Jena"抛出

The program is doing about 30 queries on the same form, but some of them "hangs" for about a minute or two before Jena throws a

 com.hp.hpl.jena.sparql.resultset.ResultSetException: Not an ResultSet result

如果我捕获到异常并继续,则某些查询将挂起,并且某些查询会快速返回包含0个或多个结果的结果集.这样做几次,返回或挂起"的查询是随机的.有时将SPARQL DBpedia与相同的查询一起使用,有时会以相同的方式在Web浏览器中挂起.

If I catch the exception and go on, some queries hang and some returns a result set quickly with either 0 or more results. Doing this several times, it's random what queries that returns or "hangs". Using the SPARQL DBpedia with a identical query sometimes works, sometimes hangs in the same way in the web browser.

  • 我是否在错误地构建查询,这在某种程度上使dbpedia.org费时,从而使服务器超时?我对Semantic Web和Jena还是很陌生,但是我最初认为查询不是很耗时,因为我在

  • Am I constructing the query wrong, making it in some way time consuming for dbpedia.org so that the query timeout at the sever? I'm quite new to the Semantic Web and Jena, but I thought initially my query not could be very time consuming since I'm using a absolute URI for the object part in the

?album p:artist <http://www.dbpedia.org/resource/SomeArtist> 

声明.

从一个来源/每个时间单位到dbpedia.org的请求是否有一些我不知道的请求?

Is there some number of requests from-one-source/per-time-unit limit to dbpedia.org that I'm not aware of?

(使用耶拿2.6.4)

(Using Jena 2.6.4)

推荐答案

我可以确认查询速度很慢.

I can confirm that the query is slow.

我尝试了一些可能会影响速度的变化,但没有帮助.抱歉,我看不出任何明显的原因使这种查询特别慢.

I tried a few variations that might effect the speed, but it didn't help. I can't see any obvious reason why that type of query would be particularly slow, sorry.

要获得更一致的响应时间,一种替代方法是下载DBPedia转储,grep提取您感兴趣的谓词,然后将其加载到本地三元存储中,例如耶拿.

One alternative, to get more consistent response times would be to download the DBPedia dump, grep out the predicates that you're interested in, and load them into a local triplestore, e.g. Jena.

这篇关于“超时/查询挂起";从耶拿(Jena)对DBpedia执行SPARQL查询时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆