|
1 |
| -This query continuously look for bars where people are falling in love like Paolo and Francesca in Dante's Divine Comedy because of a book by Gallehault. |
| 1 | +This query continuously look for bars where people are falling in love like [http://en.wikipedia.org/wiki/Francesca_da_Rimini#In_Inferno Paolo and Francesca in Dante's Divine Comedy] because of a book by [http://en.wikipedia.org/wiki/Galehaut Gallehault]. |
2 | 2 |
|
3 | 3 | The query checks :
|
| 4 | +* over the default graph containing the points of interest (POIs) of http://somesocialnetwork.org/ that the POI is a bar. |
| 5 | +* over the entire stream from http://someinvasivesensornetwork.org, that pairs of people entered in the poi in different moments within 4 hours. |
| 6 | +* over the same stream, with a long lasting time window of 1 hour, that pairs of those people have been staying close by for at least 30 minutes. Note: that this may require some resoning being the property isCloseBy symmetric. |
| 7 | +* over the same stream but with a short time window of 10 minutes, that the same pairs exit together. |
4 | 8 |
|
5 |
| - over the default graph containing the points of interest (POIs) of http://somesocialnetwork.org/ that the POI is a bar. |
6 |
| - over the entire stream from http://someinvasivesensornetwork.org, that pairs of people entered in the poi in different moments within 4 hours. |
7 |
| - over the same stream, with a long lasting time window of 1 hour, that pairs of those people have been staying close by for at least 30 minutes. Note: that this may require some resoning being the property isCloseBy symmetric. |
8 |
| - over the same stream but with a short time window of 10 minutes, that the same pairs exit together. |
| 9 | +As output, for each bar, it streams out an RDF graph with the list of pairs and the total number of pairs that felt in love. |
9 | 10 |
|
10 |
| -As output, for each bar, it streams out an RDF graph with the list of pairs and the total number of pairs that felt in love. |
| 11 | +Note that this example query covers features of C-SPARQL, CQELS, and SPARQL-Stream as well as new features missing in all RSP languages: |
| 12 | +* From C-SPARQL it takes the REGISTER clause, the FROM STREAM clause as dataset clause, the AT clause to access the timestamp (in C-SPARQL, AT is implemented with the timestamp() function) and the aggregates (which are computed in parallel without shrinking the result set, but extending it). |
| 13 | +* From CQELS it takes the idea of the STREAM keyword in the WHERE clause, herein defined as WINDOW. |
| 14 | +* From SPARQL-Stream it takes the ISTREAM clasue, that ask the RSP engine to use the R2S operator, and the notion of windows in the past. |
11 | 15 |
|
12 |
| -Note that this example query covers features of C-SPARQL, CQELS, SPARQL-Stream, EP-SPARQL as well as new features missing in all RSP languages: |
13 |
| - |
14 |
| - From C-SPARQL it takes the REGISTER clause, the FROM STREAM clause as dataset clause, the AT clause to access the timestamp (in C-SPARQL, AT is implemented with the timestamp() function) and the aggregates (which are computed in parallel without shrinking the result set, but extending it). |
15 |
| -# so what is the AT time function doing? where is that timestamp coming from? |
16 |
| - From CQELS it takes the idea of the STREAM keyword in the WHERE clause. |
17 |
| - From SPARQL-Stream it takes the ISTREAM clasue that ask the RSP engine to use the R2S operator. |
18 |
| - |
19 |
| - From EP-SPARQL, it takes the SEQ and the WITH DURATION clauses (in EP-SPARQL, WITHIN DURATION is implemented with the getDuration() function). |
20 |
| - |
21 |
| --->if we introduces new keyword SEQ for expressing order constraint, why don't we introduce keywords for 13 Allen's interval operator? for instance, BEFORE/MEETS/OVERLAPS/STARTS/DURING/FINISHES/EQUAL + inverse version of them (practically, it's the same effort for parsing) |
| 16 | +Differently from a previous version of this query, it no longer covers features of EP-SPARQL such as SEQ or the getDuration() function. This reflects the decision to layer the complex event processing language on a continuous querying one. |
22 | 17 |
|
23 | 18 | The new features are:
|
| 19 | +* the usage of an IRI to identify the query (and its stream of results) |
| 20 | +* the optional UNDER ENTAILMENT REGIME clause |
| 21 | +* the FROM NAMED WINDOW ON STREAM <<stream iri>> <<window>> AS << window name>> clause in the dataset declaration |
| 22 | +* the WINDOW keyword in the WHERE clause |
24 | 23 |
|
25 |
| - the usage of an IRI to identify the query (and its stream of results) |
26 |
| - the optional UNDER ENTAILMENT REGIME clause |
27 |
| - the FROM NAMED STREAM <<stream iri>> <<window>> AS << window name>> clause in the dataset declaration |
28 |
| - the WINDOW keyword in the WHERE clause |
29 |
| - --> is there any shorter way to express this? for instance, just STREAM keyword inside WHERE? |
30 |
| - |
31 |
| -# this looks a bit different than sparql in terms of order of query blocks, would it harm to make it something like: |
32 |
| -# PREFIX ... |
33 |
| -# CONSTRUCT ISTREAM { ...etc |
34 |
| -# FROM .... |
35 |
| -# WHERE { ... |
36 |
| -# AS :GallehaultWasTheBar |
37 |
| -# UNDER ENTAILMENT xxx... |
38 |
| - |
39 |
| -PREFIX e: <http://somevocabulary.org/> |
40 |
| -PREFIX s: <http://someinvasivesensornetwork.org/streams#> |
41 |
| -PREFIX g: <http://somesocialnetwork.org/graphs#> |
42 |
| -PREFIX : <http://acrasycompany.org/rsp#> |
43 |
| -REGISTER STREAM :GallehaultWasTheBar |
44 |
| -UNDER ENTAILMENT REGIME <http://www.w3.org/ns/entailment/RIF> |
45 |
| -AS |
46 |
| -FROM NAMED STREAM s:1 |
47 |
| -FROM NAMED STREAM s:1 [RANGE PT1H STEP PT5M] AS :longWindow #it is strange to reference to :longWindow as NAMED STREAM here and WINDOW later... and can create confusion on users. Wouldn't be better to use the same keyword in both cases? |
48 |
| -FROM NAMED STREAM s:1 [RANGE PT10M STEP PT5M] AS :shortWindow |
49 |
| -FROM NAMED GRAPH g:SocialGraph |
50 |
| -FROM GRAPH g:POIs |
51 |
| -CONSTRUCT ISTREAM { |
52 |
| - ?poi rdf:type :Gallehault ; |
53 |
| - :count ?howmanycouples ; |
54 |
| - :for (?somebody ?someoneelse) # I cannot understand this one clearly |
55 |
| -} |
56 |
| -WHERE { |
57 |
| - ?poi rdf:type e:bar . |
58 |
| - STREAM s:1 { |
59 |
| - { ?somebody e:enters ?poi } |
60 |
| - SEQ |
61 |
| - { ?someoneelse ex:enters ?poi } WITHIN PT4H |
62 |
| - } |
63 |
| - # is this equivalent to : ? |
64 |
| - # STREAM s:1 [RANGE PT1H STEP PT5M] { |
65 |
| - WINDOW :longWindow { |
66 |
| - { ?somebody e:isCloseTo ?someoneelse |
67 |
| - MINUS { ?somebody e:isCloseTo ?yetanotherone . FILTER (?yetanotherone != ?someoneelse) } |
68 |
| - } WITH DURATION ?longtime |
69 |
| - FILTER (?longtime>"PT30M"^^xsd:duration) |
| 24 | +<tt> |
| 25 | + PREFIX e: <http://somevocabulary.org/> |
| 26 | + PREFIX s: <http://someinvasivesensornetwork.org/streams#> |
| 27 | + PREFIX g: <http://somesocialnetwork.org/graphs#> |
| 28 | + PREFIX : <http://acrasycompany.org/rsp> |
| 29 | + REGISTER STREAM :GallehaultWasTheBar |
| 30 | + UNDER ENTAILMENT REGIME <http://www.w3.org/ns/entailment/RIF> |
| 31 | + AS |
| 32 | + FROM NAMED WINDOW ON STREAM s:1 [RANGE PT4H STEP PT1H] AS :veryLongWindow |
| 33 | + FROM NAMED WINDOW ON STREAM s:1 [FROM NOW-PT35M TO NOW-PT5M STEP PT5M] AS :longWindow |
| 34 | + FROM NAMED WINDOW ON STREAM s:1 [RANGE PT10M STEP PT5M] AS :shortWindow |
| 35 | + FROM NAMED GRAPH g:SocialGraph |
| 36 | + FROM GRAPH g:POIs |
| 37 | + CONSTRUCT ISTREAM { |
| 38 | + ?poi rdf:type :Gallehault ; |
| 39 | + :count ?howmanycouples ; |
| 40 | + :for (?somebody ?someoneelse) |
| 41 | + } |
| 42 | + WHERE { |
| 43 | + ?poi rdf:type e:bar . |
| 44 | + WINDOW :veryLongWindow { |
| 45 | + ?somebody e:enters ?poi |
| 46 | + ?someoneelse e:enters ?poi |
| 47 | + } |
| 48 | + WINDOW :longWindow { |
| 49 | + ?somebody e:isCloseTo ?someoneelse |
| 50 | + MINUS { ?somebody e:isCloseTo ?yetanotherone . FILTER (?yetanotherone != ?someoneelse) } |
| 51 | + } |
| 52 | + WINDOW :shortWindow { |
| 53 | + { ?somebody e:exits ?bar} BEGIN AT ?t1 |
| 54 | + { ?someoneelse e:exits ?bar } BEGIN AT ?t2 |
| 55 | + FILTER (abs(?t2-?t1)<"PT1M"^^xsd:duration ) |
| 56 | + } |
| 57 | + GRAPH g:1 { |
| 58 | + FILTER NOT EXIST { ?somebody e:knows ?someoneelse } |
| 59 | + } |
| 60 | + FILTER (?somebody != ?someoneelse) |
70 | 61 | }
|
71 |
| - # not sure if we need both WITHIN and WITH DURATION+FILTER |
72 |
| - WINDOW :shortWindow { |
73 |
| - { ?somebody e:exits ?bar} AT ?t1 |
74 |
| - { ?someoneelse e:exits ?bar } AT ?t2 |
75 |
| - FILTER (abs(?t2-?t1)<"PT1M"^^xsd:duration ) |
| 62 | + AGGREGATE { |
| 63 | + GROUP BY ?bar |
| 64 | + COUNT(?somebody) AS ?howmanycouples |
76 | 65 | }
|
77 |
| - GRAPH g:1 { |
78 |
| - FILTER NOT EXIST { ?somebody e:knows ?someoneelse } |
79 |
| - } |
80 |
| - FILTER (?somebody != ?someoneelse) |
81 |
| -} |
82 |
| -AGGREGATE { |
83 |
| - GROUP BY ?bar |
84 |
| - COUNT(?somebody) AS ?howmanycouples |
85 |
| -} |
86 |
| - |
87 |
| -#are we creating a different type of aggregate syntax? i.e. not the one from SPARQL1.1? ok, for the construct you need something else, but could it be done with a subquery right? |
| 66 | +</tt> |
0 commit comments