首先我应该提到我正在使用C-SPARQL,它用于流推理,所以我有三元组的时间戳。下面是一个查询,它返回给我一个主题和谓词,以及使用C-SPARQL中的时间戳函数分配给它的最新时间戳(我希望),但我希望它返回与此时间戳关联的对象值同样。有任何想法吗?我试图将其粘贴到select子句中,但这会产生一个非组键错误。
"REGISTER QUERY StreamQuery AS "
+ "PREFIX ex: <http://localhost/default/tr069#> "
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
+ "SELECT DISTINCT ?s ?p (MAX(f:timestamp(?s,?p,?o)) AS ?ts)"
+ "FROM STREAM <http://localhost/default/tr069> [RANGE 5s STEP 1s] "
+ "WHERE { ?s ?p ?o . "
+ "} GROUP BY ?s ?p "
如果我还不够清楚,请问。
编辑:经过一番摆弄后,我似乎得到的结果看起来是正确的结果,并不介意听到别人对我所做的事情的看法。"REGISTER QUERY StreamQuery AS "
+ "PREFIX ex: <http://localhost/default/tr069#> "
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
+ "SELECT DISTINCT ?s ?p ?o "
+ "FROM STREAM <http://localhost/default/tr069> [RANGE 5s STEP 1s] "
+ "WHERE { ?s ?p ?o . "
+ "{SELECT ?s ?p (MAX(f:timestamp(?s,?p,?o)) AS ?ts) WHERE{?s ?p ?o} GROUP BY ?s ?p}"
+ " FILTER(f:timestamp(?s,?p,?o)=?ts) } "