Open rahuldh2006 opened 2 years ago
Hi @rahuldh2006,
Just to understand the question correctly, this is only for static data? So you have a named graph http://streamreasoning.org/roomConnection which contains the static data of your rooms? And then you join it with the stream in a later phase?
KR
Hi Pieter,
The query above was just example. My use case with RSP4J is : Use static data model as a context database. Perform stream reasoning on incoming stream, where the reasoning queries would also use the data from this context database. After reasoning, the output stream would update this context database (if any of its data needs to be updated based on the stream).
To achieve the above use case in CSparql2 inside RSP4J, I want to add a static named model like done below in CSparql1.0 : engine.putStaticNamedModel("http://streamreasoning.org/roomConnection", CsparqlUtils.serializeRDFFile("examples_files/roomConnection.rdf")); After that, i would execute general queries and update queries on this static model.
How can i do this in CSparql2 / RSP4J ? Please correct me if wrong. Thanks.
Regards, Rahul
Hi Rahul,
Yes, you can definetly use static data with RSP4J! CSPARQL2 and RSP4J use the RSP-QL model under the hood and accept RSP-QL queries. You can define the static data you want to use directly in the query, for example:
PREFIX ars: <http://www.streamreasoning/artist#>
PREFIX afn: <http://jena.apache.org/ARQ/function#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX : <http://differenthost:12134/>
REGISTER RSTREAM <out> AS
SELECT *
FROM NAMED WINDOW <win2> ON :stream2 [RANGE PT5S STEP PT0.5S]
FROM <file:///.../rsp4j/csparql2/src/test/resources/static.ttl>
WHERE {
?a ars:hasName ?name.
WINDOW ?w {
?a a ars:Artist ;
ars:hasAge ?age .
}
BIND( UUID() as ?uuid )
}
In the query above the FROM clause loads the static data which then can be queried inside the default graph. You can see the example here for CSPARQL2.0.
YASPER is our own from scratch implementation on top of RSP4j, you can register the same query there as well.
Let me know if this solves your problem!
Kr, Pieter
In Csparql 1.0, we execute query over data source (static knowledge) as below:
String generalQuery = "SELECT ?val FROM http://localhost:8080/csparql_web_server/demo.rdf "
String updateQuery = "PREFIX : http://www.streamreasoning.org/ontologies/sr4ld2014-onto# "
"{ GRAPH http://streamreasoning.org/roomConnection { :room :isConnectedTo :room2 } }";
RDFTable queryResult = engine.evaluateGeneralQueryOverDatasource(generalQuery);
engine.execUpdateQueryOverDatasource(updateQuery);
How do we do similar to above using CSparql 2.0 in RSP4J?