Embed presentation
Downloaded 60 times

![http://streamreasoning.org/events/rsp2016Share, Remix, Reuse — Legally This work is licensed under the Creative CommonsAttribution 3.0 Unported License. You are free:• to Share — to copy, distribute and transmit the work• to Remix — to adapt the work Under the following conditions• Attribution — You must attribute the work by inserting– “[source http://streamreasoning.org/rsp2014]” at the end ofeach reused slide– a credits slide stating- These slides are partially based on “RDF Stream Processing 2014”by M. Balduini, J-P Calbimonte, O. Corcho, D. Dell'Aglio, E. DellaValle http://streamreasoning.org/rsp2014 To view a copy of this license, visithttp://creativecommons.org/licenses/by/3.0/2](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-2-2048.jpg&f=jpg&w=240)



![http://streamreasoning.org/events/rsp2016 6RDF Stream…GiGi+1Gi+2…Gi+n…unboundedsequenceGi {(s1,p1,o1),(s2,p2,o2),…} [ti]1+ triplesimplicit/explicittimestamp/intervalRDF streams in theoryHow do I code this?Use Web standards?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-6-2048.jpg&f=jpg&w=240)














![http://streamreasoning.org/events/rsp2016 21R2RML Mappings21:ObsValueMaprr:subjectMap [rr:template "http://opensense.epfl.ch/data/ObsResult_NO2_{sensor}_{time}"];rr:predicateObjectMap [rr:predicate qu:numericalValue;rr:objectMap [ rr:column "no2"; rr:datatype xsd:float; ]];rr:predicateObjectMap [rr:predicate obs:uom;rr:objectMap [ rr:parentTriplesMap :UnitMap; ]].:ObservationMaprr:subjectMap [rr:template "http://opensense.epfl.ch/data/Obs_NO2_{sensor}_{time}"];rr:predicateObjectMap [rr:predicate ssn:observedProperty;rr:objectMap [ rr:constant opensense:NO2]];URI of subjectURI of predicateObject: colum nameColumn names in a templateCan be used for mapping both databases, CSVs, JSON, etc](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-21-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016 23RDF Streams in W3C RSP:g1 {:axel :isIn :RedRoom. :darko :isIn :RedRoom}{:g1, prov:generatedAtTime, "2015-06-18T12:00:00Z"^^xsd:dateTime}:g2 {:axel :isIn :BlueRoom. }{:g2, prov:generatedAtTime, "2015-06-18T12:00:35"^^xsd:dateTime}:g3 {:minh :isIn :RedRoom. }{:g3, prov:generatedAtTime, "2015-06-18T12:02:07"^^xsd:dateTime}...https://www.w3.org/community/rsp/http://streamreasoning.github.io/RSP-QL/RSP_Requirements_Design_Document/Graph-basedFlexible timepropertyRDF-friendlyFlexiblemetadata:g_1 :startsAt "2015-06-18T12:00:00"^^xsd:dateTime:g_1 :endsAt "2015-06-18T13:00:00"^^xsd:dateTime:g_2 :validBetween [:startsAt "2015-06-18T12:00:00"^^xsd:dateTime;:endsAt "2015-06-18T13:00:00"^^xsd:dateTime]Intervals](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-23-2048.jpg&f=jpg&w=240)









![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageQuery registration - Example Using the social stream fb, Who is where?REGISTER QUERY QWhoIsWhereOnFb ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?room ?personFROM STREAM <http://…/fb> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .} The resulting variable bindings has to be interpreted as aninstantaneous. It expires as soon as the query isrecomputed33](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-33-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageStream registration - Example Results of a C-SPARQL query can be stream out for downstream queriesREGISTER STREAM SWhoIsWhereOnFb ASPREFIX : <http://…/sr4ld2014-onto#>CONSTRUCT { ?person :isIn ?room }FROM STREAM <http://…/fb> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .} The resulting RDF triples are streamed out on an RDFstream• More details in the C-SPARQL Engine hands-on session34](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-34-2048.jpg&f=jpg&w=240)




![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageFROM STREAM Clause - Example Using the social stream fb, how many people are in thesame room? Count on a window of 1 minute that slidesevery 10 secondsREGISTER QUERY HowManyPoepleAreInTheSameRoom ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?room (COUNT(DISTINCT ?s) as ?person)FROM STREAM <http://…/fb> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .}GROUP BY ?room40](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-39-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016 41C-SPARQL LanguageC-SPARQL reports only snapshotstt+10t+20t+30t+40t+50t+60t+70t+80d1d2d3d1 d1 d1 d1 d1d2 d2 d2 d2d3 d3IncomingtimestampedRDF triplesTime window [RANGE 40s STEP 10s] Windowcontentt+40d1d1, d2d1, d2d1, d2, d3d2, d3t+50 t+60 t+70 t+80](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-40-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageMultiple FROM STREAM Clause - Example Using the social stream fb and fs, how many people arein the same room? Count on a window of 1 minute thatslides every 10 secondsREGISTER QUERY HowManyPoepleAreInTheSameRoom ASPREFIX : <http://…/rsp2014-onto#>SELECT ?room (COUNT(DISTINCT ?s) as ?person)FROM STREAM <http://…/fb> [RANGE 1m STEP 10s]FROM STREAM <http://…/fs> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .}GROUP BY ?room42](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-41-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageQuery Chaining A C-SPARQL query Q1 registered using the STREAM clausestreams results on an RDF stream A down stream C-SPARQL query Q2 can open a window onthe RDF stream of Q1 using the FROM STREAM clause E.g.,43Is in on 4query4StreamfStreamIs with on fqueryIs In acrossf and 4queryStreamStream:Bob :posts [ :who :Bob ; :where :BlueRoom ] .:Carl :posts [ :who :Carl , :Bob ] .:Bob :isIn :BlueRoom .:Carl :isWith :Bob .:Carl :isIn :BlueRoom .](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-42-2048.jpg&f=jpg&w=240)


![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageTimeStamp Function - Example Who is “following” whom?REGISTER QUERY FindFollowers ASPREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#>PREFIX : <http://…/sr4ld2014-onto#>SELECT ?someOne ?someOneElse ?roomFROM STREAM <http://…/isIn> [RANGE 1m STEP 10s]WHERE {?someOne :isIn ?room .?someOneElse :isIn ?room .FILTER(?someOne!=?someOneElse )FILTER (f:timestamp(?someOne :isIn ?room) <f:timestamp(?someOneElse :isIn ?room)}46](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-45-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageAccessing background Information C-SPARQL allows for asking the engine to issue the queryalso against RDF graphs using the FROM clauses. E.g., Where else can Alice go?REGISTER QUERY WhereElseCanAliceGo ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?roomFROM STREAM <http://…/isIn> [RANGE 10m STEP 10m]FROM <http://…/bgInfo>WHERE {?:Alice :isIn ?someRoom .?someRoom :isConnectedTo ?room .}47IRI identifying the graphcontaining thebackground information](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-46-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageC-SPARQL queries and reasoning - example Memo• posts is a sub property of observes Data Query under RDFS entailment regimeREGISTER QUERY QueryUnderRDFSEntailmentRegime ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?x ?room ?personFROM STREAM <http://…/fs> [RANGE 1m STEP 10s]FROM STREAM <http://…/sensors> [RANGE 1m STEP 10s]WHERE { ?x :observes [ :who ?person ; :where ?room ] .} Results at t2 + 10s48RDF graph Time-stamp Stream:RedSensor :observes [ :who :Alice; :where :RedRoom ] . t1 sensors:Bob :posts [ :who :Bob ; :where :RedRoom] . t2 fs?x ?room ?person:RedSensor :RedRoom :Alice:Bob :RedRoom :Bob](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-47-2048.jpg&f=jpg&w=240)







![http://streamreasoning.org/events/rsp2016Morph-streams: Overview56QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsMorph-streams procesing SPARQLStream queriesSELECT ?proximityFROM STREAM<http://streamreasoning.org/SensorReadings.srdf> [NOW–5 S]WHERE {?obs a ssn:ObservationValue;qudt:numericalValue ?proximity;FILTER (?proximity>10) }SELECT proxFROM sens.win:time(5 sec)WHERE prox >10π timed,proxωσprox>105 SecondssensDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOther](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-55-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016SPARQLStream Language NamedStream ‘FROM’ [‘NAMED’] ‘STREAM’ StreamIRI ‘[’ Window ‘]’ Window ‘NOW-’ Integer TimeUnit [UpperBound] [Slide] UpperBound ‘TO NOW-’ Integer TimeUnit Slide ‘SLIDE’ Integer TimeUnit TimeUnit ‘MS’ | ‘S’ | ‘MINUTES’| ‘HOURS’ | ‘DAY’ Select ‘SELECT’ [Xstream] [Distinct | Reduced] … Xstream ‘RSTREAM’ | ‘ISTREAM’ | ‘DSTREAM’58SELECT ISTREAM ?roomFROM NAMED STREAM <http://www.streamreasoning.org/streams/socialsensor.srdf> [NOW-10 S]WHERE {…](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-57-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016SPARQLStream: examples59PREFIX sr4ld: <http://www.streamreasoning.org/ontologies/socialsensor,owl#>SELECT ?roomFROM NAMED STREAM <http://www.streamreasoning.org/streams/socialsensor.srdf> [NOW-10 S]WHERE {?obs sr4ld:observedBy ?sensor.?obs sr4ld:where ?room.}SPARQLStreamAll rooms where something was observed in the last 10sPREFIX sr4ld: <http://www.streamreasoning.org/ontologies/socialsensor,owl#>SELECT (COUNT(?person) AS ?nmb) ?roomFROM NAMED STREAM <http://www.streamreasoning.org/streams/socialsensor.srdf> [NOW-10 S]WHERE {?obs sr4ld:who ?pers.?obs sr4ld:where ?room.}GROUP BY ?roomNumber of persons observed in each room in the last 10s](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-58-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Underlying Query ProcessorsEsper• CEP/DSMS• EPL languageSNEE• DSMS/Sensor Network Query Evaluator• Compile queries to sensor codeGSN• Sensor middleware• REST APICosm/Xively• Sensor middleware• Open platform• REST API60SELECT prox FROM sensors [FROM NOW-5MINUTES TO NOW]WHERE prox >10SELECT prox FROM sensors.win:time(5 minute)WHERE prox >10http://montblanc.slf.ch:22001/multidata?vs[0]=sensors&field[0]=proximity_field&c_min[0]=10&from=15/05/2012+05:00:00&to=15/05/2012+10:00:00http://api.cosm.com/v2/feeds/14321/datastreams/4?start=2012-05-15T05:00:00Z&end=2012-05-15T10:00:00Z](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-59-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Morph-streams: Overview61QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsMorph-streams procesing SPARQLStream queriesSELECT ?proximityFROM STREAM<http://streamreasoning.org/SensorReadings.srdf> [NOW–5S]WHERE {?obs a ssn:ObservationValue;qudt:numericalValue ?proximity;FILTER (?proximity>10) }SELECT proxFROM sens.win:time(5 sec)WHERE prox >10π timed,proxωσprox>105 SecondssensDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOther](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-60-2048.jpg&f=jpg&w=240)



![http://streamreasoning.org/events/rsp2016Encoding in R2RML65:triplesMap a rr:TriplesMap;rr:logicalTable [ rr:tableName ”sensors"; ]rr:subjectMap [rr:template "http://streamreasoning.org/data/Observation/{person}{timed}";rr:class sr4ld:Observation; rr:graph sr4ld:socialstream.srdf ];rr:predicateObjectMap [rr:predicate sr4ld:who ;rr:objectMap [ rr:template “http://streamreasoning.org/data/Person/{person}” ]];.the streamnamesubject URItriple predicate + objectMapping definitionstreamattributesthe object (a URI in this case)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-64-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Underlying Query Processors66SELECT ?proximityFROM STREAM <http://streamreasoning.org/SensorReadings.srdf>[NOW–5 S]WHERE {?obs a ssn:ObservationValue;qudt:numericalValue ?proximity;FILTER (?proximity>10) }SELECT prox FROM sensors [FROM NOW-5 MINUTES TO NOW]WHERE prox >10timed,proxπωσprox>105 SecondssensorsSELECT prox FROM sensors.win:time(5 minute)WHERE prox >10http://montblanc.slf.ch:22001/multidata?vs[0]=sensors&field[0]=proximity_field&c_min[0]=10&from=15/05/2012+05:00:00&to=15/05/2012+10:00:00http://api.cosm.com/v2/feeds/14321/datastreams/4?start=2012-05-15T05:00:00Z&end=2012-05-15T10:00:00ZQueryrewritingR2RMLSNEE (DSMS)Esper (CEP)GSN (middlwr)Cosm XivelySPARQLStream](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-65-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016Morph-streams: With reasoning!68QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsMorph-streams procesing SPARQLStream queriesDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOtherOntologyTBoxRewrite taking into accountthe ontology TBox](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-67-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Reasoning with Morph-streams Rewriting the SPARQLStream queries:69SELECT ?xFROM NAMED STREAM <http://linkeddata.es/s/obs.srdf> [NOW - 5 MINUTES]WHERE {?x ssn:observedBy ?y}SELECT ?xFROM NAMED STREAM <http://linkeddata.es/s/obs.srdf> [NOW - 5 MINUTES]WHERE {{?x ssn:observedBy ?y}UNION{?x a ssn:Observation}UNION{?x a aws:TemperatureObservation}UNION{?x a aws:HumidityObservation}}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-68-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Morph-streams: With reasoning!70QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOtherOntologyTBoxRewrite only happens onceQueryrewriting+translationThen continuous query is registered](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-69-2048.jpg&f=jpg&w=240)




![http://streamreasoning.org/events/rsp2016 75ExecContext context=new ExecContext(HOME, false);String queryString =" SELECT ?person ?loc …ContinuousSelect selQuery=context.registerSelect(queryString);selQuery.register(new ContinuousListener(){public void update(Mapping mapping){String result="";for(Iterator<Var> vars=mapping.vars();vars.hasNext();)result+=" "+ context.engine().decode(mapping.get(vars.next()));System.out.println(result);}});RSP QueryingExample with CQELS (code.google.com/p/cqels)CQELS continuous query:get result updatesaddinglistenerregisterquerySELECT ?person ?loc WHERE {STREAM <http://deri.org/streams/rfid> [RANGE 3s]{?person :detectedAt ?loc}}Tightly coupled listenersResults delivery: push & pull?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-74-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016 76CQELS fed by a TripleWave WebSocketval conf = ConfigFactory.load.getConfig("experiments.rsp")val qq="""CONSTRUCT { ?s ?p ?o }WHERE {STREAM <ws://localhost:4040/primus> [RANGE 0ms]{?s ?p ?o}}"""val sys=new RspSystem("wstreams")val cqels=new CqelsEnginesys.startStream(Props(new WebSocketStream(cqels,"ws://localhost:4040/primus",conf)))cqels.registerQuery(qq, cqels.createListener(lissy))def lissy(triples:TripleList):Unit={println("tikki: "+triples)}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-75-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Similar models,similar (not equals!) query languages77SELECT ?sensorFROM NAMED STREAM <http://www.cwi.nl/SRBench/observations> [NOW-3 HOURS SLIDE 10 MINUTES]WHERE {?observation om-owl:procedure ?sensor ;om-owl:observedProperty weather:WindSpeed ;om-owl:result [ om-owl:floatValue ?value ] . }GROUP BY ?sensor HAVING ( AVG(?value) >= "74"^^xsd:float )SELECT ?sensorWHERE {STREAM <http://www.cwi.nl/SRBench/observations> [RANGE 10800s SLIDE 600s] {?observation om-owl:procedure ?sensor ;om-owl:observedProperty weather:WindSpeed ;om-owl:result [ om-owl:floatValue ?value ] .} }GROUP BY ?sensor HAVING ( AVG(?value) >= "74"^^xsd:float )SELECT ?sensorFROM STREAM <http://www.cwi.nl/SRBench/observations> [RANGE 1h STEP 10m]WHERE {?observation om-owl:procedure ?sensor ;om-owl:observedProperty weather:WindSpeed ;om-owl:result [ om-owl:floatValue ?value ] . }GROUP BY ?sensor HAVING ( AVG(?value) >= "74"^^xsd:float )SPARQLStreamCQELSC-SPARQL](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-76-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016 79W3C RSP-CG: RSP-QLPREFIX e: <http://somevocabulary.org/>PREFIX s: <http://someinvasivesensornetwork.org/streams#>PREFIX g: <http://somesocialnetwork.org/graphs#>PREFIX : <http://acrasycompany.org/rsp>REGISTER STREAM :GallehaultWasTheBarUNDER ENTAILMENT REGIME <http://www.w3.org/ns/entailment/RIF> AS CONSTRUCT ISTREAM {?poi rdf:type :Gallehault ;:count ?howmanycouples ;:for (?somebody ?someoneelse) }FROM NAMED WINDOW :veryLongWindow ON s:1 [RANGE PT4H STEP PT1H]FROM NAMED WINDOW :longWindow ON s:1 [FROM NOW-PT35M TO NOW-PT5M STEP PT5M]FROM NAMED WINDOW :shortWindow ON s:1 [RANGE PT10M STEP PT5M]FROM NAMED GRAPH g:SocialGraphFROM GRAPH g:POIsWHERE {?poi rdf:type e:bar .WINDOW :veryLongWindow {{?somebody e:enters ?poi} BEGIN AT ?t3{?someoneelse e:enters ?poi} BEGIN AT ?t4FILTER(?t3>?t4)}WINDOW :longWindow {{ ?somebody e:isCloseTo ?someoneelse MINUS {?somebody e:isCloseTo ?yetanotherone .FILTER (?yetanotherone != ?someoneelse) }} WITH DURATION ?durationFILTER (?duration>="PT30M"^^xsd:duration)}WINDOW :shortWindow {{ ?somebody e:exits ?bar} BEGIN AT ?t1{ ?someoneelse e:exits ?bar } BEGIN AT ?t2FILTER (abs(?t2-?t1)<"PT1M"^^xsd:duration )}GRAPH g:SocialGraph {FILTER NOT EXIST { ?somebody e:knows ?someoneelse }}FILTER (?somebody != ?someoneelse)}AGGREGATE { GROUP BY ?poi COUNT(?somebody) AS ?howmanycouples }Continuously look forbars where people arefalling in love (because oa book )RegisterstreamTime windowsSequencingDurationStored GraphsAggregatesAccess to timeReasoningThey entered the same barThey are close to each other,with no-one elseThey get out togetherDidn’t know each other](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-78-2048.jpg&f=jpg&w=240)




![http://streamreasoning.org/events/rsp2016 84RDF Streams: Actorsval sys=ActorSystem.create("system")val consumer=sys.actorOf(Props[RdfConsumer])class Streamer extends StreamRDF{override def triple(triple:Triple){consumer ! triple}}class RdfConsumer extends Actor{def receive= {case t:Triple =>if (t.predicateMatches(RDF.‘type‘))println(s"received triple $t")}RDF consumerActor receive methodImplements behaviorMessage-passing modelRDF producerAsync message passing](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-83-2048.jpg&f=jpg&w=240)

















![http://streamreasoning.org/events/rsp2016 103Query with SPARQLval queryStr = """select distinct ?Conceptwhere {[] a ?Concept} LIMIT 10"""val query = sparql(queryStr)query.serviceSelect("http://dbpedia.org/sparql").foreach{implicit qs=>println(res("Concept").getURI)}val f=Future(query.serviceSelect("http://es.dbpedia.org/sparql")).fallbackTo(Future(query.serviceSelect("http://dbpedia.org/sparql")))f.recover{case e=> println("Error "+e.getMessage)}f.map(_.foreach{implicit qs=>println(res("Concept").getValue)})Remote SPARQL endpoinSimplified access toQuery solutionsFutures: asnyc executionNon blocking codeFallback alternative execut](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-101-2048.jpg&f=jpg&w=240)



This document provides an overview of RDF stream processing and existing RDF stream processing engines. It discusses RDF streams and how sensor data can be represented as RDF streams. It also summarizes some existing RDF stream processing query languages and systems, including C-SPARQL, and the features they support like continuous execution, operators, and time-based windows. The document is intended as a tutorial for developers on working with RDF stream processing.

![http://streamreasoning.org/events/rsp2016Share, Remix, Reuse — Legally This work is licensed under the Creative CommonsAttribution 3.0 Unported License. You are free:• to Share — to copy, distribute and transmit the work• to Remix — to adapt the work Under the following conditions• Attribution — You must attribute the work by inserting– “[source http://streamreasoning.org/rsp2014]” at the end ofeach reused slide– a credits slide stating- These slides are partially based on “RDF Stream Processing 2014”by M. Balduini, J-P Calbimonte, O. Corcho, D. Dell'Aglio, E. DellaValle http://streamreasoning.org/rsp2014 To view a copy of this license, visithttp://creativecommons.org/licenses/by/3.0/2](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-2-2048.jpg&f=jpg&w=240)



![http://streamreasoning.org/events/rsp2016 6RDF Stream…GiGi+1Gi+2…Gi+n…unboundedsequenceGi {(s1,p1,o1),(s2,p2,o2),…} [ti]1+ triplesimplicit/explicittimestamp/intervalRDF streams in theoryHow do I code this?Use Web standards?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-6-2048.jpg&f=jpg&w=240)














![http://streamreasoning.org/events/rsp2016 21R2RML Mappings21:ObsValueMaprr:subjectMap [rr:template "http://opensense.epfl.ch/data/ObsResult_NO2_{sensor}_{time}"];rr:predicateObjectMap [rr:predicate qu:numericalValue;rr:objectMap [ rr:column "no2"; rr:datatype xsd:float; ]];rr:predicateObjectMap [rr:predicate obs:uom;rr:objectMap [ rr:parentTriplesMap :UnitMap; ]].:ObservationMaprr:subjectMap [rr:template "http://opensense.epfl.ch/data/Obs_NO2_{sensor}_{time}"];rr:predicateObjectMap [rr:predicate ssn:observedProperty;rr:objectMap [ rr:constant opensense:NO2]];URI of subjectURI of predicateObject: colum nameColumn names in a templateCan be used for mapping both databases, CSVs, JSON, etc](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-21-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016 23RDF Streams in W3C RSP:g1 {:axel :isIn :RedRoom. :darko :isIn :RedRoom}{:g1, prov:generatedAtTime, "2015-06-18T12:00:00Z"^^xsd:dateTime}:g2 {:axel :isIn :BlueRoom. }{:g2, prov:generatedAtTime, "2015-06-18T12:00:35"^^xsd:dateTime}:g3 {:minh :isIn :RedRoom. }{:g3, prov:generatedAtTime, "2015-06-18T12:02:07"^^xsd:dateTime}...https://www.w3.org/community/rsp/http://streamreasoning.github.io/RSP-QL/RSP_Requirements_Design_Document/Graph-basedFlexible timepropertyRDF-friendlyFlexiblemetadata:g_1 :startsAt "2015-06-18T12:00:00"^^xsd:dateTime:g_1 :endsAt "2015-06-18T13:00:00"^^xsd:dateTime:g_2 :validBetween [:startsAt "2015-06-18T12:00:00"^^xsd:dateTime;:endsAt "2015-06-18T13:00:00"^^xsd:dateTime]Intervals](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-23-2048.jpg&f=jpg&w=240)









![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageQuery registration - Example Using the social stream fb, Who is where?REGISTER QUERY QWhoIsWhereOnFb ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?room ?personFROM STREAM <http://…/fb> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .} The resulting variable bindings has to be interpreted as aninstantaneous. It expires as soon as the query isrecomputed33](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-33-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageStream registration - Example Results of a C-SPARQL query can be stream out for downstream queriesREGISTER STREAM SWhoIsWhereOnFb ASPREFIX : <http://…/sr4ld2014-onto#>CONSTRUCT { ?person :isIn ?room }FROM STREAM <http://…/fb> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .} The resulting RDF triples are streamed out on an RDFstream• More details in the C-SPARQL Engine hands-on session34](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-34-2048.jpg&f=jpg&w=240)




![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageFROM STREAM Clause - Example Using the social stream fb, how many people are in thesame room? Count on a window of 1 minute that slidesevery 10 secondsREGISTER QUERY HowManyPoepleAreInTheSameRoom ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?room (COUNT(DISTINCT ?s) as ?person)FROM STREAM <http://…/fb> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .}GROUP BY ?room40](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-39-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016 41C-SPARQL LanguageC-SPARQL reports only snapshotstt+10t+20t+30t+40t+50t+60t+70t+80d1d2d3d1 d1 d1 d1 d1d2 d2 d2 d2d3 d3IncomingtimestampedRDF triplesTime window [RANGE 40s STEP 10s] Windowcontentt+40d1d1, d2d1, d2d1, d2, d3d2, d3t+50 t+60 t+70 t+80](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-40-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageMultiple FROM STREAM Clause - Example Using the social stream fb and fs, how many people arein the same room? Count on a window of 1 minute thatslides every 10 secondsREGISTER QUERY HowManyPoepleAreInTheSameRoom ASPREFIX : <http://…/rsp2014-onto#>SELECT ?room (COUNT(DISTINCT ?s) as ?person)FROM STREAM <http://…/fb> [RANGE 1m STEP 10s]FROM STREAM <http://…/fs> [RANGE 1m STEP 10s]WHERE {?person1 :posts [ :who ?person ; :where ?room ] .}GROUP BY ?room42](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-41-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageQuery Chaining A C-SPARQL query Q1 registered using the STREAM clausestreams results on an RDF stream A down stream C-SPARQL query Q2 can open a window onthe RDF stream of Q1 using the FROM STREAM clause E.g.,43Is in on 4query4StreamfStreamIs with on fqueryIs In acrossf and 4queryStreamStream:Bob :posts [ :who :Bob ; :where :BlueRoom ] .:Carl :posts [ :who :Carl , :Bob ] .:Bob :isIn :BlueRoom .:Carl :isWith :Bob .:Carl :isIn :BlueRoom .](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-42-2048.jpg&f=jpg&w=240)


![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageTimeStamp Function - Example Who is “following” whom?REGISTER QUERY FindFollowers ASPREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#>PREFIX : <http://…/sr4ld2014-onto#>SELECT ?someOne ?someOneElse ?roomFROM STREAM <http://…/isIn> [RANGE 1m STEP 10s]WHERE {?someOne :isIn ?room .?someOneElse :isIn ?room .FILTER(?someOne!=?someOneElse )FILTER (f:timestamp(?someOne :isIn ?room) <f:timestamp(?someOneElse :isIn ?room)}46](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-45-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageAccessing background Information C-SPARQL allows for asking the engine to issue the queryalso against RDF graphs using the FROM clauses. E.g., Where else can Alice go?REGISTER QUERY WhereElseCanAliceGo ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?roomFROM STREAM <http://…/isIn> [RANGE 10m STEP 10m]FROM <http://…/bgInfo>WHERE {?:Alice :isIn ?someRoom .?someRoom :isConnectedTo ?room .}47IRI identifying the graphcontaining thebackground information](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-46-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016C-SPARQL LanguageC-SPARQL queries and reasoning - example Memo• posts is a sub property of observes Data Query under RDFS entailment regimeREGISTER QUERY QueryUnderRDFSEntailmentRegime ASPREFIX : <http://…/sr4ld2014-onto#>SELECT ?x ?room ?personFROM STREAM <http://…/fs> [RANGE 1m STEP 10s]FROM STREAM <http://…/sensors> [RANGE 1m STEP 10s]WHERE { ?x :observes [ :who ?person ; :where ?room ] .} Results at t2 + 10s48RDF graph Time-stamp Stream:RedSensor :observes [ :who :Alice; :where :RedRoom ] . t1 sensors:Bob :posts [ :who :Bob ; :where :RedRoom] . t2 fs?x ?room ?person:RedSensor :RedRoom :Alice:Bob :RedRoom :Bob](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-47-2048.jpg&f=jpg&w=240)







![http://streamreasoning.org/events/rsp2016Morph-streams: Overview56QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsMorph-streams procesing SPARQLStream queriesSELECT ?proximityFROM STREAM<http://streamreasoning.org/SensorReadings.srdf> [NOW–5 S]WHERE {?obs a ssn:ObservationValue;qudt:numericalValue ?proximity;FILTER (?proximity>10) }SELECT proxFROM sens.win:time(5 sec)WHERE prox >10π timed,proxωσprox>105 SecondssensDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOther](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-55-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016SPARQLStream Language NamedStream ‘FROM’ [‘NAMED’] ‘STREAM’ StreamIRI ‘[’ Window ‘]’ Window ‘NOW-’ Integer TimeUnit [UpperBound] [Slide] UpperBound ‘TO NOW-’ Integer TimeUnit Slide ‘SLIDE’ Integer TimeUnit TimeUnit ‘MS’ | ‘S’ | ‘MINUTES’| ‘HOURS’ | ‘DAY’ Select ‘SELECT’ [Xstream] [Distinct | Reduced] … Xstream ‘RSTREAM’ | ‘ISTREAM’ | ‘DSTREAM’58SELECT ISTREAM ?roomFROM NAMED STREAM <http://www.streamreasoning.org/streams/socialsensor.srdf> [NOW-10 S]WHERE {…](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-57-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016SPARQLStream: examples59PREFIX sr4ld: <http://www.streamreasoning.org/ontologies/socialsensor,owl#>SELECT ?roomFROM NAMED STREAM <http://www.streamreasoning.org/streams/socialsensor.srdf> [NOW-10 S]WHERE {?obs sr4ld:observedBy ?sensor.?obs sr4ld:where ?room.}SPARQLStreamAll rooms where something was observed in the last 10sPREFIX sr4ld: <http://www.streamreasoning.org/ontologies/socialsensor,owl#>SELECT (COUNT(?person) AS ?nmb) ?roomFROM NAMED STREAM <http://www.streamreasoning.org/streams/socialsensor.srdf> [NOW-10 S]WHERE {?obs sr4ld:who ?pers.?obs sr4ld:where ?room.}GROUP BY ?roomNumber of persons observed in each room in the last 10s](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-58-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Underlying Query ProcessorsEsper• CEP/DSMS• EPL languageSNEE• DSMS/Sensor Network Query Evaluator• Compile queries to sensor codeGSN• Sensor middleware• REST APICosm/Xively• Sensor middleware• Open platform• REST API60SELECT prox FROM sensors [FROM NOW-5MINUTES TO NOW]WHERE prox >10SELECT prox FROM sensors.win:time(5 minute)WHERE prox >10http://montblanc.slf.ch:22001/multidata?vs[0]=sensors&field[0]=proximity_field&c_min[0]=10&from=15/05/2012+05:00:00&to=15/05/2012+10:00:00http://api.cosm.com/v2/feeds/14321/datastreams/4?start=2012-05-15T05:00:00Z&end=2012-05-15T10:00:00Z](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-59-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Morph-streams: Overview61QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsMorph-streams procesing SPARQLStream queriesSELECT ?proximityFROM STREAM<http://streamreasoning.org/SensorReadings.srdf> [NOW–5S]WHERE {?obs a ssn:ObservationValue;qudt:numericalValue ?proximity;FILTER (?proximity>10) }SELECT proxFROM sens.win:time(5 sec)WHERE prox >10π timed,proxωσprox>105 SecondssensDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOther](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-60-2048.jpg&f=jpg&w=240)



![http://streamreasoning.org/events/rsp2016Encoding in R2RML65:triplesMap a rr:TriplesMap;rr:logicalTable [ rr:tableName ”sensors"; ]rr:subjectMap [rr:template "http://streamreasoning.org/data/Observation/{person}{timed}";rr:class sr4ld:Observation; rr:graph sr4ld:socialstream.srdf ];rr:predicateObjectMap [rr:predicate sr4ld:who ;rr:objectMap [ rr:template “http://streamreasoning.org/data/Person/{person}” ]];.the streamnamesubject URItriple predicate + objectMapping definitionstreamattributesthe object (a URI in this case)](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-64-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Underlying Query Processors66SELECT ?proximityFROM STREAM <http://streamreasoning.org/SensorReadings.srdf>[NOW–5 S]WHERE {?obs a ssn:ObservationValue;qudt:numericalValue ?proximity;FILTER (?proximity>10) }SELECT prox FROM sensors [FROM NOW-5 MINUTES TO NOW]WHERE prox >10timed,proxπωσprox>105 SecondssensorsSELECT prox FROM sensors.win:time(5 minute)WHERE prox >10http://montblanc.slf.ch:22001/multidata?vs[0]=sensors&field[0]=proximity_field&c_min[0]=10&from=15/05/2012+05:00:00&to=15/05/2012+10:00:00http://api.cosm.com/v2/feeds/14321/datastreams/4?start=2012-05-15T05:00:00Z&end=2012-05-15T10:00:00ZQueryrewritingR2RMLSNEE (DSMS)Esper (CEP)GSN (middlwr)Cosm XivelySPARQLStream](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-65-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016Morph-streams: With reasoning!68QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsMorph-streams procesing SPARQLStream queriesDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOtherOntologyTBoxRewrite taking into accountthe ontology TBox](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-67-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Reasoning with Morph-streams Rewriting the SPARQLStream queries:69SELECT ?xFROM NAMED STREAM <http://linkeddata.es/s/obs.srdf> [NOW - 5 MINUTES]WHERE {?x ssn:observedBy ?y}SELECT ?xFROM NAMED STREAM <http://linkeddata.es/s/obs.srdf> [NOW - 5 MINUTES]WHERE {{?x ssn:observedBy ?y}UNION{?x a ssn:Observation}UNION{?x a aws:TemperatureObservation}UNION{?x a aws:HumidityObservation}}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-68-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Morph-streams: With reasoning!70QueryrewritingQueryProcessingClientSPARQLStream[tuples][triples/bindings]AlgebraexpressionR2RMLMappingsDatatranslationSNEEEsperGSNCosmpull/pushhttps://github.com/jpcik/morph-streamsOtherOntologyTBoxRewrite only happens onceQueryrewriting+translationThen continuous query is registered](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-69-2048.jpg&f=jpg&w=240)




![http://streamreasoning.org/events/rsp2016 75ExecContext context=new ExecContext(HOME, false);String queryString =" SELECT ?person ?loc …ContinuousSelect selQuery=context.registerSelect(queryString);selQuery.register(new ContinuousListener(){public void update(Mapping mapping){String result="";for(Iterator<Var> vars=mapping.vars();vars.hasNext();)result+=" "+ context.engine().decode(mapping.get(vars.next()));System.out.println(result);}});RSP QueryingExample with CQELS (code.google.com/p/cqels)CQELS continuous query:get result updatesaddinglistenerregisterquerySELECT ?person ?loc WHERE {STREAM <http://deri.org/streams/rfid> [RANGE 3s]{?person :detectedAt ?loc}}Tightly coupled listenersResults delivery: push & pull?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-74-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016 76CQELS fed by a TripleWave WebSocketval conf = ConfigFactory.load.getConfig("experiments.rsp")val qq="""CONSTRUCT { ?s ?p ?o }WHERE {STREAM <ws://localhost:4040/primus> [RANGE 0ms]{?s ?p ?o}}"""val sys=new RspSystem("wstreams")val cqels=new CqelsEnginesys.startStream(Props(new WebSocketStream(cqels,"ws://localhost:4040/primus",conf)))cqels.registerQuery(qq, cqels.createListener(lissy))def lissy(triples:TripleList):Unit={println("tikki: "+triples)}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-75-2048.jpg&f=jpg&w=240)
![http://streamreasoning.org/events/rsp2016Similar models,similar (not equals!) query languages77SELECT ?sensorFROM NAMED STREAM <http://www.cwi.nl/SRBench/observations> [NOW-3 HOURS SLIDE 10 MINUTES]WHERE {?observation om-owl:procedure ?sensor ;om-owl:observedProperty weather:WindSpeed ;om-owl:result [ om-owl:floatValue ?value ] . }GROUP BY ?sensor HAVING ( AVG(?value) >= "74"^^xsd:float )SELECT ?sensorWHERE {STREAM <http://www.cwi.nl/SRBench/observations> [RANGE 10800s SLIDE 600s] {?observation om-owl:procedure ?sensor ;om-owl:observedProperty weather:WindSpeed ;om-owl:result [ om-owl:floatValue ?value ] .} }GROUP BY ?sensor HAVING ( AVG(?value) >= "74"^^xsd:float )SELECT ?sensorFROM STREAM <http://www.cwi.nl/SRBench/observations> [RANGE 1h STEP 10m]WHERE {?observation om-owl:procedure ?sensor ;om-owl:observedProperty weather:WindSpeed ;om-owl:result [ om-owl:floatValue ?value ] . }GROUP BY ?sensor HAVING ( AVG(?value) >= "74"^^xsd:float )SPARQLStreamCQELSC-SPARQL](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-76-2048.jpg&f=jpg&w=240)

![http://streamreasoning.org/events/rsp2016 79W3C RSP-CG: RSP-QLPREFIX e: <http://somevocabulary.org/>PREFIX s: <http://someinvasivesensornetwork.org/streams#>PREFIX g: <http://somesocialnetwork.org/graphs#>PREFIX : <http://acrasycompany.org/rsp>REGISTER STREAM :GallehaultWasTheBarUNDER ENTAILMENT REGIME <http://www.w3.org/ns/entailment/RIF> AS CONSTRUCT ISTREAM {?poi rdf:type :Gallehault ;:count ?howmanycouples ;:for (?somebody ?someoneelse) }FROM NAMED WINDOW :veryLongWindow ON s:1 [RANGE PT4H STEP PT1H]FROM NAMED WINDOW :longWindow ON s:1 [FROM NOW-PT35M TO NOW-PT5M STEP PT5M]FROM NAMED WINDOW :shortWindow ON s:1 [RANGE PT10M STEP PT5M]FROM NAMED GRAPH g:SocialGraphFROM GRAPH g:POIsWHERE {?poi rdf:type e:bar .WINDOW :veryLongWindow {{?somebody e:enters ?poi} BEGIN AT ?t3{?someoneelse e:enters ?poi} BEGIN AT ?t4FILTER(?t3>?t4)}WINDOW :longWindow {{ ?somebody e:isCloseTo ?someoneelse MINUS {?somebody e:isCloseTo ?yetanotherone .FILTER (?yetanotherone != ?someoneelse) }} WITH DURATION ?durationFILTER (?duration>="PT30M"^^xsd:duration)}WINDOW :shortWindow {{ ?somebody e:exits ?bar} BEGIN AT ?t1{ ?someoneelse e:exits ?bar } BEGIN AT ?t2FILTER (abs(?t2-?t1)<"PT1M"^^xsd:duration )}GRAPH g:SocialGraph {FILTER NOT EXIST { ?somebody e:knows ?someoneelse }}FILTER (?somebody != ?someoneelse)}AGGREGATE { GROUP BY ?poi COUNT(?somebody) AS ?howmanycouples }Continuously look forbars where people arefalling in love (because oa book )RegisterstreamTime windowsSequencingDurationStored GraphsAggregatesAccess to timeReasoningThey entered the same barThey are close to each other,with no-one elseThey get out togetherDidn’t know each other](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-78-2048.jpg&f=jpg&w=240)




![http://streamreasoning.org/events/rsp2016 84RDF Streams: Actorsval sys=ActorSystem.create("system")val consumer=sys.actorOf(Props[RdfConsumer])class Streamer extends StreamRDF{override def triple(triple:Triple){consumer ! triple}}class RdfConsumer extends Actor{def receive= {case t:Triple =>if (t.predicateMatches(RDF.‘type‘))println(s"received triple $t")}RDF consumerActor receive methodImplements behaviorMessage-passing modelRDF producerAsync message passing](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-83-2048.jpg&f=jpg&w=240)

















![http://streamreasoning.org/events/rsp2016 103Query with SPARQLval queryStr = """select distinct ?Conceptwhere {[] a ?Concept} LIMIT 10"""val query = sparql(queryStr)query.serviceSelect("http://dbpedia.org/sparql").foreach{implicit qs=>println(res("Concept").getURI)}val f=Future(query.serviceSelect("http://es.dbpedia.org/sparql")).fallbackTo(Future(query.serviceSelect("http://dbpedia.org/sparql")))f.recover{case e=> println("Error "+e.getMessage)}f.map(_.foreach{implicit qs=>println(res("Concept").getValue)})Remote SPARQL endpoinSimplified access toQuery solutionsFutures: asnyc executionNon blocking codeFallback alternative execut](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2frspimplementations-161017052540%2f75%2fRDF-Stream-Processing-Tutorial-RSP-implementations-101-2048.jpg&f=jpg&w=240)

