<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Towards Comparing RDF Stream Processing Semantics?</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Minh Dao-Tran</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Harald Beck</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Thomas Eiter</string-name>
          <email>eiterg@kr.tuwien.ac.at</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Information Systems, Vienna University of Technology Favoritenstraße 9-11</institution>
          ,
          <addr-line>A-1040 Vienna</addr-line>
          ,
          <country country="AT">Austria</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The increasing popularity of RDF Stream Processing (RSP) has led to developments of data models and processing engines which diverge in several aspects, ranging from the representation of RDF streams to semantics. Benchmarking systems such as LSBench, SRBench, and CSRBench were introduced as attempts to compare different approaches. However, these works mainly concentrate on the operational aspects. The recent logic-based LARS framework provides a theoretical underpinning to analyze stream processing/reasoning semantics. Towards comparing RSP engines at the semantic level, in this paper, we pick two representative RSP engines, namely C-SPARQL and CQELS, and propose translations from their languages and execution modes into LARS. We show the faithfulness of the translations and discuss how they can be exploited to provide a formal analysis and comparison of RSP semantics.</p>
      </abstract>
      <kwd-group>
        <kwd>RDF Stream Processing</kwd>
        <kwd>Linked-Stream Data</kwd>
        <kwd>Semantics Comparison</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Within the Semantic Web research area, RDF Stream Processing (RSP) recently emerged
to address challenges in querying heterogeneous data streams. This has led to
developments of data models and processing engines, which diverge in several aspects, ranging
from the representation of RDF streams, execution modes, to semantics [
        <xref ref-type="bibr" rid="ref11 ref15 ref18 ref2 ref6 ref7">2, 15, 7, 6, 11,
18</xref>
        ]. Thus, the RSP community1 was formed to establish a W3C recommendation.
      </p>
      <p>
        A standardization must start from seeing the differences between existing approaches
and thus comparing RSP engines is an important topic. Initial empirical comparisons
were carried out in SRBench [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] and LSBench [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ]. The former defined only functional
tests to verify the query languages features by the engines, while the latter measured
mismatch between the output of different engines. Later on, CSRBench [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] introduced
an oracle that pregenerates the correct answers wrt. each engine’s semantics, which are
then used to check the output returned by the engine. This approach however allows only
partial comparison between engines by referring to their ideal counterparts.
? This research has been supported by the Austrian Science Fund (FWF) projects P24090, P26471,
and W1255-N23.
1 https://www.w3.org/community/rsp/
      </p>
      <p>Due to the lack of a common language to express divergent RSP approaches, the
three works above could just look at the output of the engines and did not have further
means to explain beyond the output what caused the difference semantically.</p>
      <p>
        Recently, [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] proposed a unifying query model to explain the heterogeneity of RSP
systems. It shows a difference between two approaches represented by C-SPARQL [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ],
SPARQLStream [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] and CQELS [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ], the representative engines in the RSP community.
This work is based on extending SPARQL semantics to the stream setting.
      </p>
      <p>
        Recently, a Logic-based framework for Analyzing Reasoning over Stream (LARS)
was introduced [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. LARS can be used as a unifying language to which stream
processing/reasoning languages can be translated. It may serve as a formal host language to
express semantics and thus allows a deeper comparison that goes beyond mere looking
at the output of the respective engines. In this paper, towards comparing RSP engines at
the semantic level, we pick C-SPARQL and CQELS, and propose
– translations that capture the push- and pull- execution modes for general LARS
programs, and
– translations from the query languages of C-SPARQL and CQELS to LARS based
on a well-known translation from SPARQL to Datalog [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ].
      </p>
      <p>We show the faithfulness of the translations and discuss how they can be exploited to
provide a formal analysis and comparison of RSP semantics.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries</title>
      <p>
        This section briefly reviews RDF, SPARQL, RSP, and LARS, which will be illustrated
using the following running scenario inspired by [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
      <p>Example 1 The Sirius Cybernetics Corporation offers shop owners a real-time
geomarketing solution (RT GM ) to increase their sales. RT GM provides two services:
(i) an application that allows shop owners to push instantaneous discount coupons to a
server, and (ii) a free mobile app that fetches the coupons from shops near the phone,
matches them with the preferences specified in the user’s shopping profile, and delivers
the matched coupons to the user. Alice and Bob own shops a and b that sell shoes and
glasses, resp. At time point 10, Alice sends out a coupon for a 30% discount for men’s
MBT shoes. At time 15, Bob sends out a coupon for a 25% discount on Ray-Ban glasses.</p>
      <p>Claire has the App installed on her mobile phone and is walking near shops a and b
from time 18. She is neither interested in discounts on men’s products nor discount of
less than 20%. Therefore, she will get only the discount from shop b.
2.1</p>
      <sec id="sec-2-1">
        <title>RDF and SPARQL</title>
        <p>
          RDF is a W3C recommendation for data interchange on the Web [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. It models data as
directed labeled graphs whose nodes are resources and edges represent relations among
them. Each node can be a named resource (identified by an IRI), an anonymous resource
(a blank node), or a literal. We denote by I, B, L the sets of IRIs, blank nodes, and
literals, respectively.
        </p>
        <sec id="sec-2-1-1">
          <title>A triple (s; p; o) 2 (I [ B) I (I [ B [ L) is an RDF triple, where s is the</title>
          <p>subject, p the predicate, and o the object. An RDF graph is a set of RDF triples.
Example 2 (cont’d) Information in the scenario of Ex. 1 about products, offers from
shops, and Claire’s relative locations to shops can be stored in the following RDF graphs:
G = f : \mbt" : g classify : 1: : \rayban" : g classify : 0: : : : g
g1 = f: a : offers : c1: : c1 : on : \mbt": : c1 : reduce : 30:g
g2 = f: b : offers : c2: : c2 : on : \rayban": : c2 : reduce : 25:g
g3 = f: \claire" : isNear : a: : \claire" : isNear : b:g
A triple pattern is a tuple (sp; pp; op)2(I [ B [ V ) (I [ V ) (I [ B [ L [ V ), where V
is a set of variables. A basic graph pattern is a set of triple patterns.</p>
          <p>
            SPARQL [
            <xref ref-type="bibr" rid="ref12">12</xref>
            ], a W3C recommendation for querying RDF graphs, is essentially a
graph-matching query language. A SPARQL query is of the form H B, where B, the
body of the query, is a complex RDF graph pattern composed of basic graph patterns
with different algebraic operators such as UNION, OPTIONAL, etc.; and H, the head
of the query, is an expression that indicates how to construct the answer to the query [
            <xref ref-type="bibr" rid="ref14">14</xref>
            ].
However, SPARQL is not able to give answers under dynamic input as in the running
scenario. For this purpose, we need RSP.
2.2
          </p>
        </sec>
      </sec>
      <sec id="sec-2-2">
        <title>RDF Stream Processing</title>
      </sec>
      <sec id="sec-2-3">
        <title>RDF Streams and Temporal RDF Graphs. These two notions are introduced to</title>
        <p>extend Linked Stream Data and Linked Data with temporal aspects:
1. An RDF graph at timestamp t, denoted by G(t), is a set of RDF triples valid at
time t and called an instantaneous RDF graph. A temporal RDF graph is a sequence
G = [G(t)]; t 2 N = f0; 1; 2; : : :g, ordered by t.</p>
        <sec id="sec-2-3-1">
          <title>2. An RDF stream S is a sequence of elements hg : [t]i, where g is an RDF graph and</title>
          <p>t is a timestamp.</p>
        </sec>
        <sec id="sec-2-3-2">
          <title>Example 3 (cont’d) An input stream S of our running scenario is a sequence of ele</title>
          <p>ments hgi : [ti]i, where gi, representing an offer, is of the form in Ex. 2 and ti can be
either (i) the time point when the offer is announced by a shop owner (application time),
or (ii) the time point when gi arrives at an RSP engine (system time).</p>
          <p>Continuous Queries. Continuous queries are registered on a set of input streams and
background data, and continuously send out the answers as new input arrives at the
streams. There are two modes to execute such queries. In pull-based mode, the system is
scheduled to execute periodically independent of the arrival of data and its incoming rate;
in push-based mode, the execution is triggered as soon as data is fed into the system.</p>
          <p>
            Continuous queries in C-SPARQL and CQELS follow the approach by the
Continuous Query Language (CQL) [
            <xref ref-type="bibr" rid="ref1">1</xref>
            ], in which queries are composed of three classes of
operators, namely stream-to-relation (S2R), relation-to-relation (R2R), and
relation-tostream (R2S) operators. In the context of RSP, S2R operators are captured by windows
on RDF streams, R2R operators are resorted to SPARQL operators, and R2S operators
converts “pure” SPARQL output after R2R into output streams.
          </p>
          <p>
            As CQL is based on SQL, the background data tables and input streams all have
schemas. This makes it crystal clear to see which input tuple comes from which stream.
On the other hand, as RDF is schema-less, it is not straightforward to get this
distinction. RSP engines use different approaches to build the snapshot datasets for R2R
evaluation [
            <xref ref-type="bibr" rid="ref10">10</xref>
            ]:
(B1) C-SPARQL merges snapshots of the input streams into the default graph,
(B2) CQELS directly accesses the content of the input streams by introducing a new
“stream graph” pattern in the body of the query.
          </p>
          <p>Example 4 (cont’d) A continuous query to notify Claire with instantaneous coupons
matching her preferences can be expressed in C-SPARQL and CQELS as follows. For
readability, we write &lt;coupons&gt; instead of &lt;http://coupons&gt;, etc.</p>
          <p>SELECT ?shop ?product ?percent
FROM &lt;products&gt;</p>
          <p>STREAM &lt;coupons&gt; [RANGE 30m]</p>
          <p>STREAM &lt;locations&gt; [RANGE 5m]
WHERE {
?shop :offers ?coupon.
?coupon :reduce ?percent.
?coupon :on ?product.
?user :isNear ?shop.
?product :g_classify ?gender.</p>
          <p>FILTER
(?percent &gt;= 20 &amp;&amp; ?gender != 1)}</p>
          <p>SELECT ?shop ?product ?percent
FROM &lt;products&gt;
WHERE {</p>
          <p>STREAM &lt;coupons&gt; [RANGE 30m] {
?shop :offers ?coupon.
?coupon :reduce ?percent.</p>
          <p>?coupon :on ?product. }
STREAM &lt;locations&gt; [RANGE 5m] {</p>
          <p>?user :isNear ?shop. }
?product :g_classify ?gender.</p>
          <p>FILTER
(?percent &gt;= 20 &amp;&amp; ?gender != 1)}
Q1: Notification query in C-SPARQL
Q2: Notification query in CQELS
2.3</p>
        </sec>
      </sec>
      <sec id="sec-2-4">
        <title>Logic-oriented view on Streams, Windows and Time Reference</title>
        <p>
          We will gradually introduce the central concepts of LARS [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] tailored to the considered
fragment. We distinguish extensional atoms AE for input data and intensional atoms AI
for derived information. By A = AE [ AI , we denote the set of atoms.
Definition 1 (Stream) A stream S = (T; ) consists of a timeline T , an interval in N,
and an evaluation function : N 7! 2A. The elements t 2 T are called time points.
Intuitively, a stream S associates with each time point a set of atoms. We call S a data
stream, if it contains only extensional atoms.
        </p>
        <p>Example 5 (cont’d) The offers in the running scenario (Ex. 1) can be modeled as a data
stream D = (TD; D) with a timeline TD = [0; 50] whose time unit is minutes, and the
evaluation function D(10) = fo er (a; \mbt "; 30)g, (15)=fo er (b; \rayban"; 25)g,</p>
        <p>D(18) = fisNear (a); isNear (b)g and D(t) = ; for all t 2 TD n f10; 15; 18g. The
evaluation function D can be equally represented as</p>
        <p>D =</p>
        <p>1108 77!! ffiosNeera(ra(;a\)m;ibstN"e;a3r0()bg);g15 7! fo er (b; \rayban"; 25)g; :
To cope with the amount of data, one usually considers only recent atoms. Let S = (T; )
and S0 = (T 0; 0) be two streams s.t. S0 S, i.e., T 0 T and 0(t0) (t0) for all
t0 2 T 0. Then S0 is called a substream of S.</p>
      </sec>
      <sec id="sec-2-5">
        <title>Definition 2 (Window function) A (computable) window function w of type takes</title>
        <p>as input a stream S = (T; ), a time point t 2 T , called the reference time point, and a
vector of window parameters x for type and returns a substream S0 of S.
Important are tuple-based and time-based window functions. The former select a fixed
number of latest tuples while the latter select all atoms appearing in last n time points.
Window operators . Window functions can be accessed in formulas by window
operators. That is, an expression has the effect that is evaluated on the “snapshot”
of the stream delivered by its associated window function w .</p>
        <p>By dropping information based on time, window operators specify temporal
relevance. For each atom in a window, we control the semantics by some temporal reference.
Time Reference. Let S = (T; ) be a stream, a 2 A and B
data. Then, at time point t 2 T ,
A static background
– a holds, if a 2 (t) or a 2 B;
– 3a holds, if a holds at some time point t0 2 T ;
– 2a holds, if a holds at all time points t0 2 T ; and
– @t0 a holds, if t0 2 T and a holds at t0.</p>
        <p>Next, the set A+ of extended atoms is given by the grammar
3a j
2a;
where a 2 A and t is any time point. Expressions of form
are called window atoms.
Example 6 The window atom 303o er (Sh; Pr ; Pe) takes a snapshot of the last 30
minutes of a stream and uses the 3 operator to check whether an offer from shop Sh
on product Pr with a discount of Pe% appeared in the stream during this period.
Similarly, 53isNear (Sh) does the same job to take a snapshot of size 5 minutes of
the shops near the user.
2.4</p>
      </sec>
      <sec id="sec-2-6">
        <title>LARS Programs</title>
        <p>
          We present a fragment of the formalism in [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ].
        </p>
        <p>Syntax. A rule r is of the form (r), where H(r) = is the head and the body
of r is (r) = 1; : : : ; j ; not j+1; : : : ; not n. Here, is of form a or @ta, where
a 2 AI , and each i is either an ordinary atom or a window atom.</p>
        <p>Let B (r) = B +(r) [ B (r), where B +(r) = f i j 1 i jg is the positive and
B (r) = f i j j &lt; i ng is the negative body or r. A (LARS) program P is a set of
rules. A program is positive, if none of its rules has a negative body atom.
Example 7 (cont’d) Suppose we are given static background data B that contains
product information in a predicate of form g classify (Pr ; Ge), where Ge = 0 (resp. 1)
marks that product Pr is for women (resp., men). The following LARS rule amounts to
the queries in Example 4, under the input streams in a format as in Example 5.
ans(Sh; Pr ; Pe)</p>
        <p>303o er (Sh; Pr ; Pe); 53isNear (Sh);
g classify (Pr ; Ge); Pe
20; Ge 6= 1:
This rule works as follows. The two window atoms provide offers announced in the last 30
minutes and the shops near the user within the last 5 minutes. Together with the gender
classification of products provided by g classify , only products not for men (Ge 6= 1)
and have discount rate from 20% are concluded at the head with predicate ans.
Semantics. Let P be a LARS program. For a data stream D = (TD; vD), any stream
I = (T; ) D that coincides with D on AE is an interpretation stream for D. A tuple
M = hT; ; W; Bi is an interpretation for D, where W is a set of window functions w
such that the corresponding window operator appears in P , and B is the background
knowledge. Throughout, we assume W and B are fixed and thus also omit them.</p>
        <p>Satisfaction by M at t 2 T is as follows: M; t j= for 2 A+, if holds in (T; )
at time t; M; t j= r for rule r, if M; t j= (r) implies M; t j= H(r), where M; t j= (r),
if (i) M; t j= i for all i 2 f1; : : : ; jg and (ii) M; t 6j= i for all i 2 fj+1; : : : ; ng; and
M; t j= P for program P , i.e., M is a model of P (for D) at t, if M; t j= r for all r 2 P .
Moreover, M is minimal, if in addition no model M 0 = hT; 0; W; Bi 6= M of P exists
such that 0 .</p>
        <p>Definition 3 (Answer Stream) An interpretation stream I = (T; ) for a data stream
D I is an answer stream of program P at time t, if M = hT; ; W; Bi is a minimal
model of the reduct P M;t = fr 2 P j M; t j= (r)g. By AS(P; D; t) we denote the set
of all such answer streams I.</p>
        <p>Since RSP queries return just a single deterministic answer (which of course can
contain multiple rows) at a time point, we consider in this paper LARS programs that
have a single answer stream. By AS (P; D; t), we directly refer to the single element
of AS(P; D; t).</p>
        <sec id="sec-2-6-1">
          <title>Example 8 (cont’d) Consider background data B that contains product information as</title>
          <p>in Ex. 2. That is, B = f: : : ; g classify (\mbt "; 1); g classify (\rayban"; 0); : : :g. Take
the data stream D from Ex. 5 and let P be the LARS program consisting of the single
rule in Ex. 7. Then, I = (TI ; I ) is the only answer stream of P wrt. D and B at time
t = 18, where TI = TD and I = D [ f18 7! fans(b; \rayban"; 25)gg.
3</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Modeling RSP Queries</title>
      <p>Section 2.2 shows a divergence in realizing continuous queries in C-SPARQL and
CQELS. To be able to capture and analyze the difference between the two approaches,
we need to have a common starting point. This section proposes a formal model of RSP
queries that captures this common starting point idea, and then classifies C-SPARQL
and CQELS on the model.</p>
      <p>
        Similarly as in [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ], we ignore solution modifiers and formalize an RSP query as
a quadruple Q = (V; P; D; S), where V is a result form, P is a graph pattern, D is a
dataset,2 and S is a set of stream graph patterns. Roughly, S is a set of tuples of the
2 For simplicity, we omit instantaneous background datasets, which can be extended in a straightforward way.
form (s; !; g), where s is a stream identifier, ! is a window expression, and g is a basic
RDF graph pattern. Given a result form V , we denote by V the tuple obtained from
lexicographically ordering the set of variables in V .
      </p>
      <p>Example 9 Queries Q1 and Q2 in Ex. 4 stem from Q = (V; P; D; S), where
V = f?shop; ?pname; ?percentg
P = (P1 [ P2 [ P3) FILTER R</p>
      <p>8 ?shop : offers ?coupon: 9
P1= &lt; ?coupon : on ?product: =</p>
      <p>: ?coupon : reduce ?percent: ;
P2= f ?user</p>
      <p>: isNear ?shop: g
P3= f ?product : g classify ?gender: g
R = (?percent
D = f&lt;products&gt;g</p>
      <p>20 &amp;&amp; ?gender 6= 1)
S =
(&lt;http://coupons&gt;; [RANGE 30m]; P1);
(&lt;http://locations&gt;; [RANGE 5m]; P2)
:
This query covers all common aspects of Q1 and Q2 which both access the static dataset
at &lt;products&gt; and the input streams at &lt;coupons&gt; and &lt;locations&gt; with a window
of range 30 and 5 minutes, respectively. On top of the snapshot from the input streams
together with the static dataset, a pattern matching is carried out on the graph pattern P .
Next, we show how this RSP query model captures the divergent C-SPARQL and CQELS
queries. Consider an RSP query Q.</p>
      <p>The corresponding C-SPARQL query, denoted by cs(Q), can be obtained from Q by
setting the graph patterns in all stream graph patterns in S to ;. This goes along with the
idea of C-SPARQL to merge patterns on the input streams into the default graph.</p>
      <p>A corresponding CQELS query, however, can be obtained from Q at different levels
of cautiousness: for every part of P that contains gi s.t. (si; !i; gi) 2 S, replace it with
either (i) (STREAM si !i gi), or (ii) ((STREAM si !i gi) UNION gi). The former is
a brave approach when one can make sure that the static dataset and the stream si do not
share patterns, while the latter is more cautious when one is not sure and rather expects
triples matching gi come from either the static dataset or the input streams. Therefore, Q
is corresponding to a set cq (Q) of 2jSj CQELS queries, including a brave one, a cautious
one, and the ones in between. Note that Q2 in Ex. 4 is the brave CQELS query of Q.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Capturing RSP Queries Using LARS</title>
      <p>
        We will use the following strategy to capture different RSP approaches with LARS:
(1) First, the two push- and pull-based execution modes can be applied to LARS
programs in general via two straightforward translations.
(2) Then, window expressions in RSP are translated into window operators in LARS.
(3) Next, R2R operators and the approaches in building the datasets to be evaluated by
R2R operators are captured by two slightly different translations 1 and 2, based on
the translation from SPARQL to Datalog rules in [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ].
(4) Finally, post-processing can be carried out to mimic R2S operators. Note that the
post-processing can be done operationally. Therefore, it is not of our theoretical
interest and will not be considered in this paper.
      </p>
      <p>We now go into details of (1)-(3).
4.1</p>
      <sec id="sec-4-1">
        <title>Push- and Pull-Based Execution Modes for LARS Programs</title>
        <p>This section provides two translations that capture the push- and pull-based execution
modes by means of LARS itself. Given a LARS program P and a pulling period U &gt; 0,
the translations (P ) and (P; U ) encode the push- and pull-mode by LARS rules,
respectively. Intuitively, we add to the body of each rule in P an ordinary atom trigger.
Then, rules to conclude trigger are added depending on the mode. For push-based
mode, trigger will be concluded per new incoming input triple. For pull-based mode,
the condition is that the current time point is a multiple of U .</p>
        <p>Formally speaking, for a LARS rule r, a LARS program P , a pulling period U , let
trigger (r) = H (r)</p>
        <p>B (r); trigger:
trigger (P ) = ftrigger (r) j r 2 P ^ B (r) 6= ;g</p>
        <p>(P ) = trigger (P ) [ ftrigger
(P; U ) = trigger (P ) [ ftrigger</p>
        <p>NOW p(X): j p 2 AI g
Notably, the translation for the pull-based mode needs to acquire the current time
point, which is achieved as follows. The logical constant true always holds, and thus
@T true holds for all considered time points T . By applying window operator NOW
(or equivalently 0) before, only the current time point will be selected. The following
proposition shows that and faithfully capture the execution modes.
Proposition 1 Let P be a LARS program, U be a positive integer, and D = (TD; D)
be an input stream. For every t 2 TD, it holds that
(1) If D(t) 6= ;, then AS( (P ); D; t) = AS(P; D; t)
(2) If D(t) = ;, then AS( (P ); D; t) = fDg
(3) If t % U = 0, then AS( (P; U ); D; t) = AS(P; D; t)
(4) If t % U 6= 0, then AS( (P; U ); D; t) = fDg.
4.2</p>
      </sec>
      <sec id="sec-4-2">
        <title>Translate RSP Window Expressions to LARS Window Operators</title>
        <p>
          [RANGE UNBOUNDED]
(!)
L
L;0;D
N
#
0 or NOW
1
For capturing R2R operators of continuous SPARQL queries we can exploit an existing
translation from SPARQL to Datalog rules [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ]. The difference in our setting is the
streaming input and how RSP engines take snapshots of the stream to build datasets for
SPARQL evaluation.
        </p>
        <p>
          We propose two strategies (T1) and (T2) to extend the translation in [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ] to capture
R2R operators and the ways to build snapshot datasets (B1), (B2) (cf. Section 2.2):
(T1) For (B1), we just need to make sure that the triples from the input streams are
collected into the default graph.
(T2) For (B2), we introduce one more case for translating a stream graph pattern to
        </p>
        <p>LARS rules.</p>
        <p>
          Towards formally presenting our translations, we start with a review of the translation
from SPARQL to Datalog in [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ], which has two parts:
(i) The first part imports RDF triples from the dataset into a 4-ary predicate of the
form triple(S; P; O; G), where (S; P; O) covers RDF triples and G holds a graph
identifier. This can be done with the Answer Set Programming solver dlvhex.3
(ii) For the second part, a function takes as input a result form V , a graph pattern P ,
a dataset D, an integer i&gt;0 and translates the input into a Datalog program,
recursively along P . The base case is a single RDF triple pattern, i.e., P = f(S; P; O)g.
        </p>
        <p>Intuitively, converts SPARQL operators to declarative rules.</p>
        <p>Our purpose is to provide a translation for theoretical analysis rather than for practical
implementation of RSP queries. Thus, we concentrate on (ii). For (i), we assume that
– each triple (s; p; o) from the static dataset D can be accessed by triple(s; p; o; D),
– each triple (s; p; o) arriving at a stream s at time t contributes to the evaluation
function at t under a predicate striple, that is, striple(s; p; o; s) 2 (t).
3 http://www.kr.tuwien.ac.at/research/systems/dlvhex/
(V; (S; P; O); D; S; i)
(V; (P1 AND P2); D; S; i)
= ansi(V ; D; S)</p>
        <p>triple(S; P; O; D)
= (vars(P1); P1; D; S; 2i)[
(vars(P2); P2; D; S; 2i + 1)[
ansi(V ; D; S)
ans2i(vars(P1); D; S);
ans2i+1(vars(P2); D; S):
(V; (P1 UNION P2); D; S; i) = (vars(P1); P1; D; S; 2i)</p>
        <p>(vars(P2); P2; D; S; 2i + 1)[
ansi(V [(V n vars(P1)) ! null]; D; S)
ansi(V [(V n vars(P2)) ! null]; D; S)
ans2i(vars(P1); D; S):
ans2i+1(vars(P2); D; S):
(V; (P1 MINUS P2); D; S; i) = (vars(P1); P1; D; S; 2i)[</p>
        <p>(vars(P2); P2; D; S; 2i + 1)[
ansi(V [(V n vars(P1)) ! null]; D; S)
ans2i(vars(P1); D; S);
not ans02i(vars(P1) \ vars(P2); D; S):
ans02i(vars(P1) \ vars(P2); D; S) ans2i+1(vars(P2); D; S):
(V; (P1 OPT P2); D; S; i) = (V; (P1 AND P2); D; S; i)[</p>
        <p>(V; (P1 MINUS P2); D; S; i)
(V; (P FILTER R); D; S; i) = (V; P; D; S; 2i)[</p>
        <p>LT (ansi(V ; D; S) ans2i(vars(P ); D; S); R:)
(V; (GRAPH g P ); D; S; i) = (V; P; g; S; i) for g 2 V [ I</p>
        <p>ansi(V ; D) ansi(V ; g); isIRI(g); g 6= default:</p>
        <p>
          Fig. 1: Extending translation in [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ] with input streams S
For (T1) we modify the base cases of for (S; P; O) with
(V; (S; P; O); D; S; i) = fansi(V ; D; S)
fansi(V ; D; S)
triple(S; P; O; D)g [
triple(S; P; O; S)g;
and add the following rules to import input streaming triples to the default graph:
0(S) = ftriple(S; P; O; S)
        </p>
        <p>(!)3striple(S; P; O; s) j (s; !; g) 2 Sg:
The translation for strategy (T1) is 1(V; P; D; S; i) = (V; P; D; S; i) [ 0(S).
For (T2), let 2 be a function that agrees with , and moreover fulfills:
2(V; (STREAM s ! g); D; S; i)=ansi(V ; D; S)
(!)(</p>
        <p>^
(S;P;O)2g
3striple(S; P; O; s)):
When it is clear from context, we will write in the sequel = i(Q) (i 2 f1; 2g), for a
query Q = (V; P; D; S) instead of = i(V; P; D; S; 1).</p>
        <p>
          Given an RSP query Q=(V; P; D; S), let Q02fcs(Q)g[cq (Q) and Ii=AS ( i(Q0); D; t)
for a data stream D and a time point t, where i 2 f1; 2g. We denote the set of atoms of
predicate ansj with the parameter corresponding to S projected away by
chop(I; Q) = fansj (Vj ; D) j ansj (Vj ; D; S) 2 Ig [ (I n fansj (Vj ; D; S) 2 Ig).
The following result shows that our translation preserves the translation in [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ].
Proposition 2 Let Q = (V; P; D; ;) be an RSP query, that is, a SPARQL query, and
cq (Q) = fQ0g. Let I be the single answer set of (Q), I1 = AS ( 1(cs(Q)); D; t),
and I2 = AS ( 2(Q0); D; t). It holds that I = chop(I1; Q) = chop(I2; Q).
Translations 1 and 2 share the core from translation in [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ], and differ due to two
approaches by C-SPARQL and CQELS in extending SPARQL to deal with streaming
input. Furthermore, the two engines execute on two different modes, namely pull- and
push-based. This makes it non-trivial to analyze situations in which the engines should
return the same output. Tackling this question now becomes possible with LARS, which
will be discussed next.
5
        </p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Utilizing LARS for Comparing RSP Semantics</title>
      <p>This section discusses ideas to tackle the comparison between C-SPARQL and CQELS
using LARS. The main questions are:
(i) What do we mean by saying “C-SPARQL and CQELS return the same output?”
(ii) When do the two approaches of dealing with streaming input coincide, i.e., merging
input streams into the default graph and using stream graph patterns do not make
any difference in building the datasets evaluated by the engines?
(iii) Under which conditions will the push- and pull-based executions fulfill (i)?
The most important question is (i), which establishes the whole setup and methodology
for the comparison. Since C-SPARQL and CQELS build on a pull- and push-based
mode, respectively, it does not make sense to require that the output of the two engines
coincides at every single time point. Instead, we need some notion of agreement between
the two engines. Intuitively, we say that C-SPARQL and CQELS agree on a time interval
[t1; t2], if the union of outputs returned by CQELS at every time point in (t1; t2] (i.e.,
the total output in that interval) coincides with the output returned by C-SPARQL at t2.
Assume that both two engines start at time 0 of a timeline T and C-SPARQL is executed
with a pulling period of U time units. Then, we say that the engines agree on T just if
they agree on every interval [i U; (i + 1) U ] 2 T , for i 0. On the translated LARS
programs, checking for agreement on the output boils down to checking the agreement
on the output facts of the predicate ans1.</p>
      <p>Imagine a user staring at his App to wait for notifications. If the two engines agree,
then at the end of the pulling period, the user will see the same notifications in both
cases; if the pulling period is short enough, she might even not notice any difference
between the two modes. This makes the agreement notion reasonable from a practical
point of view.</p>
      <p>Now we analyze possible sufficient conditions of agreement for C-SPARQL and
CQELS, by finding answers for questions (ii) and (iii).</p>
      <p>To put (ii) more concretely in the context of LARS, take an RSP query Q and
let Q1 = cs(Q) and Q2 2 cq (Q); we want to find conditions under which the answer
streams of 1(Q1) and 2(Q2) at time point t on the input stream D have the same
extension of predicate ans1.</p>
      <p>Observe that 1(Q1) and 2(Q2) differ on dealing with input coming from
predicate striple. The former program merges facts of striple into triple, which will
be used later on to conclude ansi; the latter program concludes ansi directly from
striple. If the static dataset and the input streams share some patterns, then 1 may
not be capable of identifying the origin of some triple. Even if the input stream does
not receive any incoming triple, 1(Q1) may still conclude some output due to facts
staying in the static part. On the other hand, 2(Q2) returns no output as the stream is
not updated. To avoid such confusion, it is required that the static dataset and the input
streams do not share patterns. Fortunately, this usually holds in practice. For instance,
in our running example, the pattern ?user :isNear ?shop can only match triples in
the stream &lt;http://locations&gt;, since predicate :isNear will not be streamed in
&lt;http://coupons&gt;, and the static dataset should not contain such information.</p>
      <p>
        When the conditions for question (ii) are fulfilled, one has a better setting to
analyze (iii). Still, for the first step, we need to assume as in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] that the execution time
of the engines is marginal compared to the input rate. Note that with these conditions,
we can for a given LARS program P compare the output of (P; U ) and (P ) in time
intervals [t1; t2] = [i U; (i + 1) U ]. As the rules in P are shared by both translations,
intuitively, the total output of ans1 by (P ) during [t1; t2] will coincide with the one
by (P; U ), if the total input to (P ) during [t1; t2] coincides with the input to the
(P; U ) at t2. Here the “input” consists of the snapshots obtained by evaluating the
windows on the streams.
      </p>
      <p>However, this condition cannot be guaranteed under high throughput. The reason
is that with dense input streams, the snapshots taken at time points near the beginning
of an interval will have high chances to collect more input than the snapshot at its end.
Thus, in practice it is rather unlikely that C-SPARQL and CQELS will agree, due to the
strong semantic implications of push/pull-based querying.</p>
      <p>Conclusions and Outlook. This paper establishes first steps towards formally
comparing two RSP semantics implemented in two well-known engines, namely C-SPARQL
and CQELS, by proposing translations to capture the languages and execution modes
of the engines, and discussing idea to formalize a notion of agreement between the two
semantics as well as a condition for it to hold. Next steps include working out these
ideas formally and implementing the translations to build a comparison benchmarking
systems of different stream processing approaches using LARS.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>A.</given-names>
            <surname>Arasu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Babu</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Widom</surname>
          </string-name>
          .
          <article-title>The CQL continuous query language: semantic foundations and query execution</article-title>
          .
          <source>VLDB J</source>
          .,
          <volume>15</volume>
          (
          <issue>2</issue>
          ):
          <fpage>121</fpage>
          -
          <lpage>142</lpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>D. F.</given-names>
            <surname>Barbieri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Braga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Ceri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E. Della</given-names>
            <surname>Valle</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Grossniklaus</surname>
          </string-name>
          .
          <article-title>C-SPARQL: a continuous query language for rdf data streams</article-title>
          .
          <source>Int. J. Semantic Computing</source>
          ,
          <volume>4</volume>
          (
          <issue>1</issue>
          ):
          <fpage>3</fpage>
          -
          <lpage>25</lpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>H.</given-names>
            <surname>Beck</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Dao-Tran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Fink</surname>
          </string-name>
          .
          <article-title>Towards a Logic-Based Framework for Analyzing Stream Reasoning</article-title>
          . In OrdRing, pages
          <fpage>11</fpage>
          -
          <lpage>22</lpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>H.</given-names>
            <surname>Beck</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Dao-Tran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Fink</surname>
          </string-name>
          .
          <article-title>Towards Ideal Semantics for Analyzing Stream Reasoning</article-title>
          . In ReactKnow,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>H.</given-names>
            <surname>Beck</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Dao-Tran</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Eiter</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Fink</surname>
          </string-name>
          . LARS:
          <article-title>A logic-based framework for analyzing reasoning over streams</article-title>
          .
          <source>In AAAI</source>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>A.</given-names>
            <surname>Bolles</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Grawunder</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Jacobi</surname>
          </string-name>
          .
          <article-title>Streaming SPARQL - extending SPARQL to process data streams</article-title>
          .
          <source>In ESWC</source>
          , pages
          <fpage>448</fpage>
          -
          <lpage>462</lpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>J.-P.</given-names>
            <surname>Calbimonte</surname>
          </string-name>
          ,
          <string-name>
            <surname>O</surname>
          </string-name>
          ´ .
          <article-title>Corcho, and</article-title>
          <string-name>
            <given-names>A. J. G.</given-names>
            <surname>Gray. Enabling</surname>
          </string-name>
          ontology
          <article-title>-based access to streaming data sources</article-title>
          .
          <source>In ISWC (1)</source>
          , pages
          <fpage>96</fpage>
          -
          <lpage>111</lpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>R.</given-names>
            <surname>Cyganiak</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Wood</surname>
          </string-name>
          , and M.
          <source>Lanthaler. RDF 1</source>
          .
          <article-title>1 Concepts and Abstract Syntax</article-title>
          . http://www.w3.org/TR/rdf11-concepts/,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>D.</given-names>
            <surname>Dell'Aglio</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Calbimonte</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Balduini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O</given-names>
            <surname>´. Corcho</surname>
          </string-name>
          , and
          <string-name>
            <given-names>E. D.</given-names>
            <surname>Valle</surname>
          </string-name>
          .
          <article-title>On Correctness in RDF Stream Processor Benchmarking</article-title>
          .
          <source>In ISWC 2013</source>
          , pages
          <fpage>326</fpage>
          -
          <lpage>342</lpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10. D.
          <string-name>
            <surname>Dell'Aglio</surname>
            ,
            <given-names>E. D.</given-names>
          </string-name>
          <string-name>
            <surname>Valle</surname>
            ,
            <given-names>J.-P.</given-names>
          </string-name>
          <string-name>
            <surname>Calbimonte</surname>
            , and
            <given-names>O.</given-names>
          </string-name>
          <string-name>
            <surname>Corcho</surname>
          </string-name>
          .
          <article-title>RSP-QL Semantics: a Unifying Query Model to Explain Heterogeneity of RDF Stream Processing Systems</article-title>
          . IJSWIS,
          <volume>10</volume>
          (
          <issue>4</issue>
          ),
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>S.</given-names>
            <surname>Groppe</surname>
          </string-name>
          .
          <source>Data Management and Query Processing in Semantic Web Databases</source>
          . Springer,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>S.</given-names>
            <surname>Harris</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Seaborne</surname>
          </string-name>
          .
          <source>SPARQL 1</source>
          .
          <article-title>1 Query Language</article-title>
          . http://www.w3.org/TR/sparql11- query/,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <given-names>J. W.</given-names>
            <surname>Lloyd</surname>
          </string-name>
          and
          <string-name>
            <given-names>R. W.</given-names>
            <surname>Topor</surname>
          </string-name>
          .
          <article-title>Making Prolog more Expressive</article-title>
          .
          <source>J. Log. Program.</source>
          ,
          <volume>1</volume>
          (
          <issue>3</issue>
          ):
          <fpage>225</fpage>
          -
          <lpage>240</lpage>
          ,
          <year>1984</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14. J. Pe´rez, M. Arenas, and
          <string-name>
            <given-names>C.</given-names>
            <surname>Gutierrez</surname>
          </string-name>
          .
          <article-title>Semantics and complexity of sparql</article-title>
          .
          <source>ACM Trans. Database Syst</source>
          .,
          <volume>34</volume>
          :16:
          <fpage>1</fpage>
          -
          <lpage>16</lpage>
          :
          <fpage>45</fpage>
          ,
          <year>September 2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>D. L. Phuoc</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Dao-Tran</surname>
            ,
            <given-names>J. X.</given-names>
          </string-name>
          <string-name>
            <surname>Parreira</surname>
            , and
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Hauswirth</surname>
          </string-name>
          .
          <article-title>A native and adaptive approach for unified processing of linked streams and linked data</article-title>
          .
          <source>In ISWC (1)</source>
          , pages
          <fpage>370</fpage>
          -
          <lpage>388</lpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>D. L. Phuoc</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Dao-Tran</surname>
            , M.-
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Pham</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Boncz</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          <string-name>
            <surname>Eiter</surname>
            , and
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Fink</surname>
          </string-name>
          .
          <article-title>Linked stream data processing engines: Facts and figures</article-title>
          .
          <source>In ISWC - ET</source>
          , pages
          <fpage>300</fpage>
          -
          <lpage>312</lpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <given-names>A.</given-names>
            <surname>Polleres</surname>
          </string-name>
          .
          <article-title>From SPARQL to rules (and back)</article-title>
          .
          <source>In WWW 2007</source>
          , pages
          <fpage>787</fpage>
          -
          <lpage>796</lpage>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>O.</given-names>
            <surname>Walavalkar</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Joshi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Finin</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Y.</given-names>
            <surname>Yesha</surname>
          </string-name>
          .
          <article-title>Streaming Knowledge Bases</article-title>
          .
          <source>In SSWS</source>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Minh Duc</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Corcho</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J. P.</given-names>
            <surname>Calbimonte. SRBench: A Streaming</surname>
          </string-name>
          <string-name>
            <surname>RDF</surname>
          </string-name>
          /SPARQL Benchmark.
          <source>In ISWC</source>
          , pages
          <fpage>641</fpage>
          -
          <lpage>657</lpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>