Home
renxiangnan edited this page Sep 9, 2016
·
1 revision
Figure 1 "Water-Resource-Management-Context":
Queries on C-SPARQL (single stream):
Q1: Which observation involves chlorine value?
REGISTER QUERY TestQuery1 AS
PREFIX ex: <http://myexample.org/>
SELECT DISTINCT ?observation
FROM STREAM <http://myexample.org/stream> [RANGE 1s STEP 1s]
WHERE{
?message ex:observeChlorine ?observation .
?observation ex:hasTag ?tag .
}
Q2: How many tags are assigned to each chlorine observation?
REGISTER QUERY TestQuery2 AS
PREFIX ex: <http://myexample.org/>
SELECT DISTINCT ?observation (COUNT(?tag) AS ?numberOfTags)
FROM STREAM <http://myexample.org/stream> [RANGE 1s STEP 1s]
WHERE{
?message ex:observeChlorine ?observation .
?observation ex:hasTag ?tag .
}
GROUP BY ?observation
ORDER BY ASC(?observation)
Q3: Which observation ID has an identification ending with "00" or ``50"?
REGISTER QUERY TestQuery3 AS
PREFIX ex: <http://myexample.org/>
SELECT ?observation (COUNT(?tag) AS ?numberOfTags)
FROM STREAM <http://myexample.org/stream> [RANGE 1s STEP 1s]
WHERE {
?message ex:observeChlorine ?observation .
?observation ex:hasTag ?tag .
FILTER ( REGEX ( STR (?observation), '00$', 'i')
|| REGEX ( STR (?observation), '50$', 'i'))
}
GROUP BY ?observation
Q4: Which chlorine observation possesses three tags?
REGISTER QUERY TestQuery4 AS
PREFIX ex: <http://myexample.org/>
PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#>
SELECT ?observation (COUNT(?tag) AS ?numberOfTags)
FROM STREAM <http://myexample.org/stream> [RANGE 1s STEP 1s]
WHERE {
?message ex:observeChlorine ?observation .
?observation ex:hasTag ?tag .
FILTER ( REGEX ( STR (?tag), '1$', 'i')
|| REGEX ( STR (?tag), '2$', 'i')
|| REGEX ( STR (?tag), '3$', 'i'))
FILTER (f:timestamp(?observation, ex:hasTag, ?tag)
>= f:timestamp(?messsage, ex:observeChlorine, ?observation))
}
GROUP BY ?observation
Q5: Which observation has an identification that ends with "00" or ``10" and how many tags assigned to this observation?
REGISTER QUERY TestQuery5 AS
PREFIX ex: <http://myexample.org/>
PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#>
SELECT ?observation ?tag (COUNT(?tag) AS ?numberOfTags)
FROM STREAM <http://myexample.org/stream> [RANGE 1s STEP 1s]
WHERE {
?message ex:observeChlorine ?observation .
?observation ex:hasTag ?tag .
FILTER ( REGEX ( STR(?observation), '00$', 'i'))
FILTER (f:timestamp(?observation, ex:hasTag, ?tag)
>= f:timestamp(?messsage, ex:observeChlorine, ?observation))}
UNION
{
?message1 ex:observeFlow ?observation.
?observation ex:hasTag ?tag.
FILTER ( REGEX ( STR (?observation), '10$', 'i'))}
}
GROUP BY ?observation
HAVING (COUNT(?tag) = 3)
ORDER BY ASC(?observation)
Q6: What is the belonging sector, timestamp, and assigned label of each chlorine observation?
REGISTER QUERY TestQuery6 AS
PREFIX ex: <http://myexample.org/>
SELECT ?sector ?manufacture_ID ?label
FROM NAMED STREAM <http://myexample.org> [RANGE 1s STEP 1s]
FROM <http://localhost:9091/project>
WHERE {
?message ex:observeChlorine ?observation .
?observation ex:isProducedBy ?sensorId .
?sensorId ex:belongsTo ?sector ;
ex:isCreatedBy ?manufacture_ID ;
rdfs:label ?label .
}
Figure 2 The GC activity of Q1 on C-SPARQL
(a) Stream Rate = 100 triples/s:
(b) Stream Rate = 1000 triples/s:
(c) Stream Rate = 10000 triples/s:
Figure 3 Asynchronous of streams on CQELS: