Discovering Exis7ng Systems:c-sparql G. Cugola E. Della - - PowerPoint PPT Presentation

discovering exis7ng systems c sparql
SMART_READER_LITE
LIVE PREVIEW

Discovering Exis7ng Systems:c-sparql G. Cugola E. Della - - PowerPoint PPT Presentation

Stream and Complex Event Processing Discovering Exis7ng Systems:c-sparql G. Cugola E. Della Valle A. Margara Politecnico


slide-1
SLIDE 1

Stream ¡and ¡Complex ¡Event ¡Processing ¡

Discovering ¡Exis7ng ¡Systems:c-­‑sparql ¡

  • G. ¡Cugola ¡ ¡ ¡ ¡E. ¡Della ¡Valle ¡

¡ ¡ ¡A. ¡Margara ¡ ¡

¡ ¡ ¡ ¡ ¡ ¡Politecnico ¡di ¡Milano ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡Vrije ¡Universiteit ¡Amsterdam ¡

cugola@elet.polimi.it a.margara@vu.nl dellavalle@elet.polimi.it

slide-2
SLIDE 2

Agenda

  • Introduction
  • RDF Stream Analysis
  • Running example
  • C-SPARQL language
  • Query and Stream Registration
  • FROM STREAM Clause
  • TimeStamp Function
  • Accessing background Information
  • Resources

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 2 ¡

slide-3
SLIDE 3

Introduc7on ¡

C-­‑SPARQL ¡Engine ¡Architecture ¡

  • Simple, ¡modular ¡

architecture ¡

  • It ¡relies ¡en7rely ¡on ¡

exis7ng ¡technologies ¡ ¡

  • Integra7on ¡of ¡ ¡
  • DSMSs ¡(Esper) ¡and ¡ ¡
  • SPARQL ¡engines ¡

(Jena-­‑ARQ) ¡

¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 3 ¡

slide-4
SLIDE 4

Introduc7on ¡

C-­‑SPARQL ¡Engine ¡Features ¡at ¡a ¡glance ¡ ¡ ¡ ¡ ¡1/2 ¡ ¡

  • Efficient ¡RDF ¡stream ¡Processing ¡ ¡
  • Con7nuous ¡queries, ¡filtering, ¡aggrega7ons, ¡joins, ¡sub-­‑

queries ¡via ¡C-­‑SPARQL ¡(a ¡SPARQL ¡1.1 ¡extension) ¡

  • Push ¡based ¡
  • High ¡throughput, ¡low ¡latency ¡
  • Minimal ¡support ¡for ¡paYern ¡detec7on ¡via ¡!mestamp ¡

func7on ¡

  • Minimal ¡support ¡for ¡"sta7c" ¡RDF ¡graph ¡access ¡(a.k.a., ¡

background ¡informa7on) ¡

  • Alert! ¡using ¡7mestamp ¡func7on ¡and ¡combining ¡with ¡

"sta7c" ¡RDF ¡graphs ¡spoil ¡performances ¡ ¡

4 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-5
SLIDE 5

Introduc7on ¡

C-­‑SPARQL ¡Engine ¡Features ¡at ¡a ¡glance ¡ ¡ ¡ ¡ ¡2/2 ¡ ¡

  • Extensible ¡Middleware ¡ ¡
  • Run7me ¡management ¡of ¡
  • RDF ¡streams ¡
  • C-­‑SPARQL ¡query ¡
  • Result ¡listerners ¡
  • API ¡driven ¡ ¡
  • Web ¡APIs ¡for ¡data ¡flow ¡management ¡and ¡service ¡

layer ¡ ¡

  • Quick ¡start ¡available ¡
  • hYp://streamreasoning.org/download ¡ ¡

5 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-6
SLIDE 6

Introduc7on ¡

C-­‑SPARQL ¡Engine ¡abstrac7ons ¡

  • CsparqlEngine ¡(eu.larkc.csparql.engine.CsparqlEngine) ¡
  • Contains ¡a ¡stream ¡and ¡a ¡query ¡registry ¡
  • RDF ¡Stream ¡(eu.larkc.csparql.cep.api.RdfStream) ¡
  • A ¡stream ¡of ¡Timestamped ¡Triples ¡

(eu.larkc.csparql.cep.api.RdfQuadruple) ¡

  • C-­‑SPARQL ¡Queries ¡(eu.larkc.csparql.streams.formats.CSparqlQuery) ¡
  • Con7nuously ¡executed ¡against ¡one ¡or ¡more ¡RDF ¡Stream ¡
  • May ¡refer ¡to ¡"sta7c" ¡RDF ¡graphs ¡
  • Can ¡be ¡started/stopped ¡
  • Result ¡Proxy ¡(eu.larkc.csparql.engine.CsparqlQueryResultProxy) ¡
  • Allows ¡mul7ple ¡clients ¡to ¡observe ¡the ¡results ¡of ¡C-­‑SPARQL ¡queries ¡
  • Result ¡FormaYer ¡(eu.larkc.csparql.core.ResultFormaYer) ¡
  • Allows ¡to ¡process ¡the ¡results ¡of ¡a ¡query ¡(RDFTable) ¡a ¡row ¡

(RDFTuble) ¡at ¡a ¡7me ¡

6 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-7
SLIDE 7

Introduc7on ¡

Combining ¡C-­‑SPARQL ¡Engine ¡abstrac7ons ¡

  • The ¡C-­‑SPARQL ¡Engine ¡processing ¡model ¡is ¡con7nuous ¡
  • RDF ¡Streams, ¡C-­‑SPARQL ¡queries, ¡result ¡proxies ¡and ¡

result ¡formaYers ¡are ¡manually ¡connected ¡to ¡form ¡ graphs ¡

7 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

C-­‑SPARQL ¡ query ¡ RDF ¡ Stream ¡ RDF ¡ Stream ¡ Result ¡ Proxy ¡ Result ¡ FormaYer ¡ Result ¡ FormaYer ¡

slide-8
SLIDE 8

Introduc7on ¡

Combining ¡C-­‑SPARQL ¡Engine ¡abstrac7ons: ¡ ¡code ¡

CsparqlEngine ¡engine ¡= ¡new ¡CsparqlEngineImpl(); ¡ engine.ini7alize(true); ¡ engine.registerStream(<<RDF ¡Stream>>); ¡ CsparqlQueryResultProxy ¡c ¡= ¡engine.registerQuery(<<query>>); ¡ c1.addObserver(<<formaYer>>); ¡ ¡ …. ¡ ¡ engine.unregisterQuery(c.getId()); ¡ ¡ engine.unregisterStream(<<RDF ¡Stream ¡IRI>>); ¡ ¡ ¡

See ¡also ¡HelloWorldCSPARQL.java ¡in ¡the ¡C-­‑SPARQL ¡ready ¡to ¡go ¡pack ¡

8 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-9
SLIDE 9

Introduc7on ¡

Chaining ¡C-­‑SPARQL ¡queries ¡

  • A ¡special ¡result ¡formaYers ¡(RDFStreamFormaYer) ¡can ¡

inject ¡the ¡results ¡of ¡C-­‑SPARQL ¡queries, ¡whose ¡form ¡is ¡ STREAM, ¡into ¡another ¡RDF ¡streams. ¡

  • MEMO: ¡RDF ¡streams ¡are ¡not ¡typed ¡

9 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

RDFStreamFormaYer ¡

slide-10
SLIDE 10

Introduc7on ¡

Chaining ¡C-­‑SPARQL ¡queries: ¡code ¡

CsparqlEngine ¡engine ¡= ¡new ¡CsparqlEngineImpl(); ¡ engine.ini7alize(true); ¡ engine.registerStream(<<RDFstream1>>); ¡ RdfStream ¡s2; ¡ s2 ¡= ¡new ¡RDFStreamForma5er(<<RDFstream2>>); ¡ engine.registerStream(s2); ¡ CsparqlQueryResultProxy ¡c1; ¡ CsparqlQueryResultProxy ¡c2; ¡ c1 ¡= ¡engine.registerQuery(<<query ¡on ¡RDFstream1>>); ¡ c1.addObserver((RDFStreamForma5er) ¡s2); ¡ c2 ¡= ¡engine.registerQuery(<<query ¡Down ¡Stream>>); ¡ c2.addObserver(<<forma9er>>); ¡

¡ See ¡also ¡the ¡COMPOSABILITY ¡case ¡in ¡HelloWorldCSPARQL.java ¡in ¡the ¡C-­‑SPARQL ¡ ready ¡to ¡go ¡pack ¡

10 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-11
SLIDE 11

RDF ¡Stream ¡Analysis ¡

Running ¡Example ¡

11 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

Topic ¡ Tweet ¡

sr:messageID(xsd:string) ¡ sr:messageTimeStamp(xsd:string) ¡ talksAbout ¡ talksAboutPosi7vely ¡ following ¡ posts ¡

TwiYerUser ¡

sr:screenName(xsd:string) ¡ likes ¡

slide-12
SLIDE 12

RDF ¡Stream ¡Analysis ¡

Streaming ¡vs. ¡Background ¡Informa7on ¡

Streaming information User related background information Topic related background information

Topic& Tweet&

sr:messageID(xsd:string)& sr:messageTimeStamp(xsd:string)& talksAbout& talksAboutPosi>vely& following& posts&

TwiBerUser&

sr:screenName(xsd:string)& likes&

slide-13
SLIDE 13

RDF ¡Stream ¡Analysis ¡

Background ¡Informa7on ¡-­‑ ¡example ¡

  • User related background information, e.g.

:Alice a :TwitterUser . :Bob a :TwitterUser . :Bob :follows :Alice .

  • See also

hYp://streamreasoning.org/larkc/csparql/LBSMA-­‑sta7c-­‑k.rdf ¡

Which is used in the STREAMING_AND_EXTERNAL_STATIC_RDF_GRAPH case of HelloWorldCSPARQL.java in the C-SPARQL ready to go pack

13 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-14
SLIDE 14

RDF ¡Stream ¡Analysis ¡

Streaming ¡Informa7on

  • RDF Stream Data Type
  • Ordered sequence of pairs, where each pair is made of an

RDF triple and its timestamp ¡ § Timestamps ¡are ¡not ¡required ¡to ¡be ¡unique, ¡they ¡must ¡be ¡non-­‑ decreasing

  • E.g.,

(<:Alice :posts :post1 >, 2010-02-12T13:34:41) (<:post1 :talksAboutPositively :LaScala>, 2010-02-12T13:34:41) (<:Bob :posts :post2 >, 2010-02-12T13:36:28) (<:post2 :talksAboutPositively :Duomo>, 2010-02-12T13:36:28)

  • See also
  • LBSMARDFStreamTestGenerator.java in the ready to go pack

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 14 ¡

slide-15
SLIDE 15

RDF ¡Stream ¡Analysis ¡

C-­‑SPARQL ¡language ¡

  • C-­‑SPARQL ¡queries ¡
  • derive ¡and ¡aggregate ¡informa7on ¡from ¡one ¡or ¡

more ¡RDF ¡streams ¡ ¡

  • to ¡join ¡or ¡merge ¡RDF ¡streams ¡ ¡
  • can ¡access ¡"sta7c" ¡RDF ¡graphs ¡and ¡ ¡
  • to ¡feed ¡results ¡from ¡one ¡RDF ¡stream ¡to ¡

subsequent ¡C-­‑SPARQL ¡query ¡

15 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-16
SLIDE 16

RDF ¡Stream ¡Analysis ¡

MEMO: ¡SPARQL ¡

16 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-17
SLIDE 17

RDF ¡Stream ¡Analysis ¡

Where ¡C-­‑SPARQL ¡Extends ¡SPARQL ¡

17 ¡

slide-18
SLIDE 18

RDF ¡Stream ¡Analysis ¡

C-­‑SPARQL ¡language ¡

  • C-­‑SPARQL ¡is ¡an ¡extension ¡of ¡SPARQL ¡1.1 ¡ ¡
  • C-­‑SPARQL ¡queries ¡
  • Adds ¡to ¡SPARQL ¡1.1 ¡query ¡forms ¡the ¡STREAM ¡

form ¡

  • Changes ¡the ¡seman7cs ¡of ¡SPARQL ¡1.1 ¡query ¡forms ¡

from ¡the ¡one-­‑7me ¡seman7cs ¡to ¡the ¡con7nuous ¡

  • ne ¡(i.e., ¡instantaneous) ¡and ¡
  • Adds ¡to ¡SPARQL ¡1.1 ¡datasets ¡clauses ¡the ¡FROM ¡

STREAM ¡one ¡

  • Adds ¡a ¡built-­‑in ¡to ¡access ¡the ¡7mestamp ¡of ¡a ¡triple ¡ ¡

18 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-19
SLIDE 19

RDF ¡Stream ¡Analysis ¡

Query ¡and ¡Stream ¡Registra7on ¡

19 ¡

slide-20
SLIDE 20

RDF ¡Stream ¡Analysis ¡

Query ¡and ¡Stream ¡Registra7on ¡

  • All ¡C-­‑SPARQL ¡queries ¡over ¡RDF ¡streams ¡are ¡

conHnuous ¡

  • Registered ¡through ¡the ¡REGISTER statement ¡ ¡
  • The ¡output ¡of ¡queries ¡is ¡in ¡the ¡form ¡of ¡ ¡
  • Instantaneous ¡tables ¡of ¡variable ¡bindings ¡ ¡
  • Instantaneous ¡RDF ¡graphs ¡
  • RDF ¡stream ¡
  • Only ¡queries ¡in ¡the ¡ ¡the ¡CONSTRUCT ¡form ¡can ¡be ¡

registered ¡as ¡generators ¡of ¡RDF ¡streams ¡ ¡ ¡

  • Composability: ¡ ¡
  • Query ¡results ¡registered ¡as ¡streams ¡can ¡feed ¡other ¡

registered ¡queries ¡just ¡like ¡every ¡other ¡RDF ¡stream ¡

¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 20 ¡

slide-21
SLIDE 21

RDF ¡Stream ¡Analysis ¡

Query registration - Example ¡

What ¡objects ¡do ¡TwiYer's ¡users ¡like? ¡ ¡

REGISTER QUERY WhatUserLikes AS PREFIX ex: <http://myexample.org/> SELECT ?u ?o FROM STREAM <http://…/twitterstream> [RANGE 1s STEP 1s] WHERE { ?u :post ?t . ?t :talksAboutPositively ?o . } GROUP BY ?o

¡ NOTE: ¡The ¡resul7ng ¡variable ¡bindings ¡has ¡to ¡be ¡interpreted ¡as ¡an ¡

  • instantaneous. ¡It ¡expires ¡as ¡soon ¡as ¡the ¡query ¡is ¡recomputed ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 21 ¡

slide-22
SLIDE 22

RDF ¡Stream ¡Analysis ¡

Stream registration - Example ¡

Results ¡of ¡a ¡C-­‑SPARQL ¡query ¡can ¡be ¡stream ¡out ¡for ¡ down ¡stream ¡queries ¡

REGISTER STREAM WhatUserLikes AS PREFIX ex: <http://myexample.org/> CONSTRUCT {?u ex:likes ?o } FROM STREAM <http://…/twitterstream> [RANGE 1s STEP 1s] WHERE { ?u :post ?t . ?t :talksAboutPositively ?o . } GROUP BY ?o

NOTE: ¡all ¡the ¡queries ¡that ¡follow ¡are ¡assumed ¡to ¡consume ¡the ¡ results ¡of ¡this ¡query ¡that ¡is ¡streamed ¡in ¡an ¡RDF ¡graph ¡whose ¡IRI ¡is ¡

http://myexample.org/stream ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 22 ¡

slide-23
SLIDE 23

RDF ¡Stream ¡Analysis ¡

Stream ¡Registra7on ¡-­‑ ¡Notes ¡

  • The ¡output ¡is ¡constructed ¡in ¡the ¡format ¡of ¡an ¡

RDF ¡stream. ¡

  • Every ¡query ¡execu7on ¡may ¡produce ¡from ¡a ¡

minimum ¡of ¡zero ¡triples ¡to ¡a ¡maximum ¡of ¡an ¡ en7re ¡graph. ¡ ¡

  • The ¡7mestamp ¡is ¡always ¡dependent ¡on ¡the ¡

query ¡execu7on ¡7me ¡only, ¡and ¡is ¡not ¡taken ¡ from ¡the ¡triples ¡that ¡match ¡the ¡paYers ¡in ¡the ¡ WHERE ¡clause. ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 23 ¡

slide-24
SLIDE 24

RDF ¡Stream ¡Analysis

FROM ¡STREAM ¡Clause ¡

24 ¡

slide-25
SLIDE 25

RDF ¡Stream ¡Analysis

FROM ¡STREAM ¡Clause ¡

  • FROM ¡STREAM ¡clauses ¡are ¡similar ¡to ¡SPARQL ¡

datasets ¡

  • They ¡idenHfy ¡RDF ¡stream ¡data ¡sources ¡
  • They ¡represent ¡windows ¡over ¡a ¡RDF ¡stream ¡ ¡
  • They ¡define ¡the ¡RDF ¡triples ¡available ¡for ¡

querying ¡and ¡filtering. ¡ ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 25 ¡

slide-26
SLIDE 26

RDF ¡Stream ¡Analysis ¡

FROM ¡STREAM ¡Clause ¡-­‑ ¡windows

  • physical: a given number of triples
  • logical: a variable number of triples which occur during a

given time interval (e.g., 1 hour)

  • Sliding: they are progressively advanced of

a given STEP (e.g., 5 minutes)

  • Tumbling: they are advanced of exactly their time interval

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 26 ¡

slide-27
SLIDE 27

RDF ¡Stream ¡Analysis

FROM ¡STREAM ¡Clause ¡-­‑ ¡Windows ¡

  • Grammar ¡of ¡the ¡FROM STREAM ¡clause ¡
  • The ¡op7onal ¡NAMED ¡keyword ¡works ¡exactly ¡like ¡

when ¡applied ¡to ¡the ¡standard ¡SPARQL ¡FROM clause ¡for ¡tracking ¡the ¡provenance ¡of ¡triples. ¡ ¡

  • It ¡binds ¡the ¡IRI ¡of ¡a ¡stream ¡to ¡a ¡variable ¡which ¡is ¡later ¡

accessible ¡through ¡the ¡GRAPH ¡clause. ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 27 ¡

'AS' ¡Name ¡

slide-28
SLIDE 28

RDF ¡Stream ¡Analysis ¡

FROM ¡STREAM ¡Clause ¡-­‑ ¡Example ¡

How ¡many ¡users ¡like ¡the ¡same ¡object? ¡Does ¡the ¡ coun7ng ¡on ¡a ¡window ¡of ¡5 ¡seconds ¡that ¡slides ¡ every ¡seconds ¡

REGISTER QUERY HowManyUsersLikeTheSameObj AS PREFIX ex: <http://myexample.org/> SELECT ?o (count(?s) as ?countUsers) FROM STREAM <http://myexample.org/stream> [RANGE 5s STEP 1s] WHERE { ?s ex:likes ?o } GROUP BY ?o

See ¡also ¡the ¡HOW_MANY_USERS_LIKE_THE_SAME_OBJ ¡case ¡in ¡ HelloWorldCSPARQL.java ¡in ¡the ¡C-­‑SPARQL ¡ready ¡to ¡go ¡pack ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 28 ¡

slide-29
SLIDE 29

RDF ¡Stream ¡Analysis ¡

C-­‑SPARQL ¡reports ¡only ¡snapshots ¡

29 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

t ¡ t+1 ¡ t+2 ¡ t+3 ¡ t+4 ¡ t+5 ¡ t+6 ¡ t+7 ¡ t+8 ¡ W1 ¡ W2 ¡ W3 ¡

W1 ¡ W1 ¡ W1 ¡ W1 ¡ W1 ¡ W2 ¡ W2 ¡ W2 ¡ W2 ¡ W3 ¡ W3 ¡

Incoming ¡ 7mestamped ¡ RDF ¡triples ¡ Time ¡window ¡[RANGE ¡4s ¡STEP ¡1s] ¡ Results ¡

At ¡t+4 ¡ ¡ ¡At ¡t+5 ¡ ¡ ¡At ¡t+6 ¡ ¡ ¡At ¡t+7 ¡ ¡ ¡At ¡t+8 ¡

W1 ¡ W1, ¡W2 ¡

¡

W1, ¡W2 ¡ W1, ¡W2, ¡W3 ¡ W2, ¡W3 ¡

slide-30
SLIDE 30

RDF ¡Stream ¡Analysis ¡

Mul7ple ¡FROM ¡STREAM ¡Clause ¡-­‑ ¡Example ¡

C-­‑SPARQL ¡queries ¡can ¡combine ¡triples ¡from ¡mul7ple ¡RDF ¡ stream, ¡e.g., ¡trendy ¡objects ¡on ¡mul7ple ¡social ¡networks ¡

REGISTER QUERY TrendyObjectsOnMultipleSN AS PREFIX ex: <http://myexample.org/> SELECT ?o (count(?s) as ?countUsers) FROM STREAM <http://myexample.org/stream> [RANGE 5s STEP 1s] FROM STREAM <http://myexample.org/anotherstream> [RANGE 5s STEP 1s] WHERE { ?s ex:likes ?o } GROUP BY ?o ORDER BY DESC(?countUsers)

See ¡also ¡the ¡MULTI_STREAM ¡case ¡in ¡HelloWorldCSPARQL.java ¡in ¡the ¡C-­‑SPARQL ¡ ready ¡to ¡go ¡pack ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 30 ¡

slide-31
SLIDE 31

RDF ¡Stream ¡Analysis ¡

Mul7ple ¡Times ¡the ¡same ¡stream ¡-­‑ ¡Example ¡

Emerging ¡as ¡trendy ¡objects ¡

REGISTER QUERY TrendyObjectsOnMultipleSN AS PREFIX ex: <http://myexample.org/> SELECT ?o (count(?s1)/count(?s2) as ?index) FROM NAMED STREAM <http://myexample.org/stream> [RANGE 5s STEP 1s] AS SHORT FROM NAMED STREAM <http://myexample.org/stream> [RANGE 5s STEP 1s] AS LONG WHERE { WINDOW SHORT {?s1 ex:likes ?o } WINDOW LONG {?s2 ex:likes ?o } } GROUP BY ?o HAVING (?index>0.9) ORDER BY DESC(?index)

¡ ALERT: ¡this ¡query ¡is ¡not ¡supported ¡by ¡the ¡current ¡C-­‑SPARQL ¡Engine ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 31 ¡

slide-32
SLIDE 32

RDF ¡Stream ¡Analysis ¡

TimeStamp ¡Func7on ¡

32 ¡

slide-33
SLIDE 33

RDF ¡Stream ¡Analysis ¡

TimeStamp ¡Func7on ¡– ¡Syntax ¡and ¡Seman7cs ¡

  • The ¡7mestamp ¡of ¡a ¡triple ¡can ¡be ¡bound ¡to ¡a ¡variable ¡

using ¡a ¡timestamp() ¡func7on ¡

  • Syntax ¡
  • 7mestamp(variable|IRI, ¡variable|IRI, ¡variable|IRI|literal) ¡
  • Seman7cs ¡

¡

Triple ¡ Result ¡of ¡evalutaion ¡ It ¡is ¡not ¡in ¡the ¡window ¡ Type ¡Error ¡ It ¡appears ¡once ¡in ¡the ¡window ¡ Timestamp ¡of ¡triple It ¡appears ¡mul7ple ¡7mes ¡in ¡ the ¡window ¡ The ¡7mestamp ¡ofmost ¡recent ¡triple ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 33 ¡

slide-34
SLIDE 34

RDF ¡Stream ¡Analysis ¡

TimeStamp ¡Func7on ¡and ¡CEP ¡ ¡

  • The ¡7mestamp ¡func7on ¡can ¡be ¡used ¡to ¡model ¡

7me ¡rela7onships ¡used ¡in ¡CEP ¡

  • E.g. ¡

A -> B

  • in ¡C-­‑SPARQL ¡

?a rdf:type :A . ?b rdf:type :B . FILTER ( timestamp(?a,rdf:type,:A) < timestamp(?b,rdf:type,:B) )

34 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-35
SLIDE 35

RDF ¡Stream ¡Analysis

TimeStamp ¡Func7on ¡-­‑ ¡Example

Who ¡are ¡the ¡opinion ¡makers? ¡i.e., ¡the ¡users ¡who ¡are ¡likely ¡ to ¡influence ¡the ¡behavior ¡of ¡other ¡users ¡ ¡

REGISTER QUERY FindOpinionMakers AS PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> PREFIX ex: <http://myexample.org/> SELECT ?opinionMaker ?o (COUNT(?follower) AS ?n) FROM STREAM <http://myexample.org/stream> [RANGE 10s STEP 5s] WHERE { ?opinionMaker ex:likes ?o . ?follower ex:likes ?o . FILTER(?opinionMaker!=?follower) FILTER (f:timestamp(?follower,ex:likes,?o) > f:timestamp(?opinionMaker,ex:likes,?o)) } GROUP BY ?opinionMaker ?o HAVING (COUNT(?follower)>3)

See ¡also ¡the ¡FIND_OPINION_MAKERS ¡case ¡in ¡HelloWorldCSPARQL.java ¡in ¡the ¡ ¡ C-­‑SPARQL ¡ready ¡to ¡go ¡pack ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 35 ¡

slide-36
SLIDE 36

RDF ¡Stream ¡Analysis

Accessing ¡background ¡Informa7on ¡

  • Accessing ¡background ¡informa7on ¡in ¡DSMSs ¡

and ¡CEPs ¡is ¡problema7c ¡and ¡it ¡can ¡spoil ¡ performances ¡

  • C-­‑SPARQL ¡allows ¡for ¡loading ¡external ¡RDF ¡

graphs ¡using ¡the ¡SPARQL ¡1.1 ¡FROM ¡clauses ¡

  • Keep ¡the ¡external ¡RDF ¡files ¡small!!! ¡
  • For ¡a ¡beYer ¡solu7on ¡see: ¡
  • Le-­‑Phuoc, ¡D., ¡Dao-­‑Tran, ¡M.: ¡A ¡na7ve ¡and ¡adap7ve ¡approach ¡for ¡unified ¡

processing ¡of ¡linked ¡streams ¡and ¡linked ¡data. ¡In: ¡Interna7onal ¡ Seman7c ¡Web ¡Conference ¡(ISWC ¡2011). ¡Volume ¡1380., ¡Bonn, ¡ Germany, ¡Springer ¡(2011) ¡370–388 ¡ ¡

36 ¡ Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡

slide-37
SLIDE 37

RDF ¡Stream ¡Analysis

Accessing ¡background ¡Informa7on ¡-­‑ ¡Example

Who ¡are ¡the ¡opinion ¡makers? ¡i.e., ¡the ¡users ¡who ¡are ¡likely ¡ to ¡influence ¡the ¡behavior ¡of ¡other ¡users ¡who ¡follow ¡them ¡

REGISTER QUERY StreamingAndExternalStaticRdfGraph AS PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> PREFIX ex: <http://myexample.org/> SELECT ?opinionMaker ?o (COUNT(?follower) AS ?n) FROM STREAM <http://myexample.org/stream> [RANGE 10s STEP 5s] FROM <http://streamreasoning.org/larkc/csparql/LBSMA-static-k.rdf> WHERE { ?opinionMaker ex:likes ?o . ?follower ex:follows ?opinionMaker . ?follower ex:likes ?o . FILTER(?opinionMaker!=?follower) FILTER (f:timestamp(?follower,ex:likes,?o) > f:timestamp(?opinionMaker,ex:likes,?o)) } GROUP BY ?opinionMaker ?o HAVING (COUNT(?follower)>3) See ¡also ¡the ¡STREAMING_AND_EXTERNAL_STATIC_RDF_GRAPH ¡case ¡in ¡ HelloWorldCSPARQL.java ¡in ¡the ¡C-­‑SPARQL ¡ready ¡to ¡go ¡pack ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 37 ¡

slide-38
SLIDE 38

Resources ¡

  • Download ¡the ¡C-­‑SPARQL ¡Ready ¡To ¡Go ¡Pack ¡
  • hYp://streamreasoning.org/download ¡
  • See ¡demos ¡
  • hYp://streamreasoning.org/demos ¡ ¡
  • Read ¡out ¡more ¡
  • D. ¡F. ¡Barbieri, ¡D. ¡Braga, ¡S. ¡Ceri, ¡E. ¡Della ¡Valle, ¡M. ¡

Grossniklaus, ¡Querying ¡RDF ¡streams ¡with ¡ ¡ C-­‑SPARQL, ¡SIGMOD ¡Record ¡39 ¡(1) ¡(2010) ¡20–26. ¡ ¡

  • Contact ¡point ¡
  • emanuele.dellavalle@polimi.it ¡ ¡

Stream ¡& ¡Complex ¡Event ¡Processing ¡-­‑ ¡Introduc7on ¡ 38 ¡