0

我一直在关注关于 Property Functions 的 ARQ 指南。图操作部分以“因此可以创建新的三元组或图作为属性函数的一部分”结束,我一直希望将其用作将三元组添加到当前查询执行上下文(而不是持久化)的方法,可用于剩余的查询。

我一直在尝试指南该部分的代码片段:

DatasetGraph datasetGraph = execCxt.getDataset();

Node otherGraphNode = NodeFactory.createURI("http://example.org/otherGraph");

Graph newGraph = new SimpleGraphMaker().createGraph();

Triple triple = ...
newGraph.add(triple);

datasetGraph.addGraph(otherGraphNode, newGraph);

但我遇到了问题,似乎是读锁。

org.apache.jena.dboe.transaction.txn.TransactionException: Can't become a write transaction
at org.apache.jena.dboe.transaction.txn.Transaction.ensureWriteTxn(Transaction.java:251) ~[fuseki-server.jar:4.2.0]
at org.apache.jena.tdb2.store.StorageTDB.ensureWriteTxn(StorageTDB.java:200) ~[fuseki-server.jar:4.2.0]
at org.apache.jena.tdb2.store.StorageTDB.add(StorageTDB.java:81) ~[fuseki-server.jar:4.2.0]
at org.apache.jena.dboe.storage.system.DatasetGraphStorage.add(DatasetGraphStorage.java:181) ~[fuseki-server.jar:4.2.0]
at org.apache.jena.dboe.storage.system.DatasetGraphStorage.lambda$addGraph$1(DatasetGraphStorage.java:194) ~[fuseki-server.jar:4.2.0]

有没有办法在 SPARQL 查询期间向执行上下文添加三元组?

4

1 回答 1

0

是的,SPARQL 任何东西都使用该功能在查询时将非 RDF 数据增加三倍,并使其在执行上下文的 DatasetGraph 中可用。

下面是一个例子:

                if (this.execCxt.getDataset().isEmpty()) {
                // we only need to call getDatasetGraph() if we have an empty one
                // otherwise we could triplify the same data multiple times
                dg = getDatasetGraph(p, opBGP);
            } else {
                dg = this.execCxt.getDataset();
            }

这些线

这个答案可能无法满足您的特定需求(添加单个三元组),但希望项目中的一些代码可以作为您正在寻找的示例。

于 2021-10-22T02:11:58.400 回答