Query Jena TDB store

限于喜欢 提交于 2019-12-06 22:54:36

It's seems my TDB is empty because model.size() return 0. I'm sure it isn't empty because I can query it with fuseki with my sparqlEndpoint.

Things can exist without having contents. The length of the string "" is 0, but it's still a string. You didn't show the results of your query

SELECT (count(*) AS ?count) { ?s ?p ?o }

Did it return 0, or something else? Also, when you do

Model model  = dataset.getDefaultModel();

you're only getting the default model of the dataset, but a dataset can contain a number of named graphs, in addition to the default graph. If you do have triples in your dataset, they might be in named graphs, in which case you could do something like

select (count(*) as ?count) { graph ?g { ?s ?p ?o } }

I don't know offhand how Fuseki handles the default graph, but it might be that the default graph of the dataset is configured (I think this can be customized) to be the union of the named graphs in the dataset. When that's the case, the result of getDefaultModel might still be an empty model. I'm speculating on that point, but it's a conceivable way that you could get results from the default graph while still having the default model be empty.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!