Skip to content
jpcik edited this page Apr 14, 2013 · 2 revisions

Test queries in SPARQLstream

These test queries show different use cases considering variations on:

  • The time window size
  • Window slide (how often the window slides) and tumbling windows
  • Special cases on windows (NOW)
  • Usage of aggregate
  • Usage of window-to-stream operators
  • Number of tuples per window

Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18

1: Short time window

Sliding window, no explicit sliding parameters. Issue: not clear what is the default behavior. If we use push, then the client receives the data "when a matching result is detected". In this case, do we have different results if we change the window size?. In principle no, unless the engine re-sends a value for some reason. This is not true if we use an aggregate, for example. In that case, (e.g. an avg) the window contents are different and produce different results.

PREFIX om-owl: <http://knoesis.wright.edu/ssw/ont/sensor-observation.owl#>
PREFIX weather: <http://knoesis.wright.edu/ssw/ont/weather.owl#>

SELECT ?sensor ?value 
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
}

2: Longer time window

Sliding window, no explicit sliding parameters.

Does anything change if we change the time window? If we pull the data the changes are noticeable, e.g. we get a "buffer of results".

SELECT ?sensor ?value 
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 60 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
}

3: Short time tumbling window

Tumbling window, with explicit slide equal to window size.

Right now in SPARQLstream with esper we cannot define slide sizes. It was possible with SNEE.

However we could easily activate tumbling windows working as foollows: window contents are buffered and released after the windows size expires. Issue: SPARQLStream with Esper cannot control slides

SELECT ?sensor ?value 
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s SLIDE 10 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
}

4: Sliding Time window, shorter slide

Sliding window, Slide is smaller than window size.

SELECT ?sensor ?value 
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s SLIDE 3 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
}

5: Sliding Time window, longer slide

Sliding window, Slide is larger than window size.

In this case there are "holes", in which data is virtually ignored from the evaluation. Is it an interesting case?

It is not currently ppossible with SPARQLStream. Idea: use output modifiers?

SELECT ?sensor ?value 
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s SLIDE 15 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
}

6: Sliding Time window, now

Special case for latest triples "NOW"

Perhaps not too interesting?. In SPARQLStream it is a shorthand for the minimal time window size. With Esper this is 1 ms.

SELECT ?sensor ?value 
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
}

7: Sliding Time window, aggregate

Using aggregates, results visibly differ if the window contents are different

SELECT (SUM(?value) AS ?sum)  
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
}

8: Two Time windows

Different streams, each with its time window

Here it is not exactly clear what is the content of both streams. Idea: separate some observations according to their type: air temp, humid, etc.

SELECT ?sensor ?value ?value2  
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s]
FROM NAMED STREAM <http://cwi.nl/SRBench/other-observations> [NOW - 5 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
  ?obs2   om-owl:observedBy ?sensor;
          om-owl:observedProperty weather:AirPressure;
          om-owl:result ?result2.
  ?result2 om-owl:floatValue ?value2.
}

9: Two Time windows, smaller windows

Different streams, each with its small time window

SELECT ?sensor ?value ?value2  
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 1 s]
FROM NAMED STREAM <http://cwi.nl/SRBench/other-observations> [NOW - 1 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
  ?obs2   om-owl:observedBy ?sensor;
          om-owl:observedProperty weather:AirPressure;
          om-owl:result ?result2.
  ?result2 om-owl:floatValue ?value2.
}

10: Two Time windows, same stream

This is not supported by SPARQLStream. Should modify the language to provide a similar support as a GRAPH in SPARQL

SELECT ?sensor ?value ?value2  
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 1 s]
FROM NAMED STREAM <http://cwi.nl/SRBench/other-observations> [NOW - 1 s]
WHERE {
STREAM <http://cwi.nl/SRBench/observations> [NOW - 1 s]{  
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value;
  }
STREAM <http://cwi.nl/SRBench/observations> [NOW - 1 s]{
  ?obs2   om-owl:observedBy ?sensor;
          om-owl:observedProperty weather:AirPressure;
          om-owl:result ?result2.
  ?result2 om-owl:floatValue ?value2.
  }
}

11: RStream

Usage of RStream operaor (both insert and delete streams)

SELECT RSTREAM ?sensor ?value
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value.
}

12: IStream

Usage of IStream operaor, only "new" tuples

SELECT ISTREAM ?sensor ?value
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value.
}

13: DStream

Usage of DStream operaor, only deleted tuples from the output stream

SELECT DSTREAM ?sensor ?value
FROM NAMED STREAM <http://cwi.nl/SRBench/observations> [NOW - 10 s]
WHERE {
  ?observation om-owl:observedBy ?sensor;
               om-owl:observedProperty weather:AirTemperature;
               om-owl:result ?result.
  ?result om-owl:floatValue ?value.
}

14: Triple stream rate

Variation on input Stream Rate: 1000/sec, 100/sec 10/sec

Can we really control the correct output of the query evaluation?, We would need to have a deterministic environment.

15: Decreasing triple stream rate

Variation: progressively from 10/sec to 1000/sec

16: Intermitent triple streams

Intervals with no triples in the input stream.

17: Controlling the Output Stream

Not supported in SPARQLStream Idea: Add an output modifier: e.g.

  • EVERY 30 SECONDS: Limits the output to only push data within this interval. Similar to a slide, but with different connotations.

18: Triple windows (aka Physical)

Not considered in SPARQLStream What is the meaning of triple windows? Consider this stream excerpt:

:obs :value "3" 
:obs :prop "temp"
:obs2 :value "4"
:obs2 :prop "temp"
  • If we ask in a query for ?obs :value ?v with a triple window of size 1, what do we get?
  • If the window is applied to the stream, and only then the pattern matching, we would get no answer. What is correct?
  • If we ask in a query for ?obs :prop ?p;:value ?v with a triple window of size 1, What do we get?
  • If the order of the triples in the stream changes, does it change the results?