sparql - 语义网 - Jena sparql

标签 sparql jena

在 sparql jena 中执行查询后,我尝试以列表形式获取查询结果,因此我使用了以下内容:

res = ResultSetFormatter.toList(results);    

但是当我在该方法之前编写此方法时,变量 res 返回 null。

ResultSetFormatter.out(System.out, results);
res = ResultSetFormatter.toList(results);    

我不知道问题出在哪里。

最佳答案

主要的ResultSet实现是com.hp.hpl.jena.sparql.engine.ResultSetStream,它只能使用一次,而您试图使用它两次。 API documentation对于 ResultSetStream 说:

The main ResultSet implementation for returning results from queries. This version is "use once" - you can not reset the result set because the results of the query are not remembered so as not to consume potentially large amounts of memory.

关于sparql - 语义网 - Jena sparql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10625841/

相关文章:

sparql - ARQ 从头开始​​查询

java - 是否有机会从现有本体中找到特定类并使用 jena 添加等效类

java - 获取传递关系中的所有节点 - 扩展

sparql - Jena Fuseki 和 Blazegraph 对于字符串文字的 'type strictness' 的行为有所不同

SPARQL 日期范围

sparql - 数据库百科/sparql : get population & lat/lng of all cities/towns/villages in UK

rdf - Fuseki 索引 (Lucene) 文本搜索不返回任何结果

android - 如何在 sparql 中使用绑定(bind)

rdf - SPARQL 过滤 COUNT

java - 在本体中创建个体的代码?