• No se han encontrado resultados

MARINELA CHOCOLATIN

Event History with Basic Operations

Definition 10 Event history H is an ordered set of primitive event instances. Time

constraint event history H[ts, te] is an ordered set of primitive event instances from history H with timestamps less than te and greater than ts.

H[ts,te] ={e|∀e ∈ H ∧ (ts ≤ e.ts ≤ e.te ≤ te)}. (5.1)

5.1. INTRODUCTION 91

semantics, at any time t, we apply a query to the window constraint event history

Hw= H[ts, te] with te := t and ts := t - w where w is an integer representing the

sliding window size.

Definition 11 Ei[Hw] selects events of type Eifrom window constrained event his-

tory Hw.

Ei[Hw] = {e|e ∈ Hw∧ (e ∈ Ei)}. (5.2)

Notations

1). The notation −→e1,ndenotes an ordered sequence of event instances e1, e2, ... ,

en such that for all pairs (ei, ej) with i < j in the sequence, ei.ts≤ ei.te <

ej.ts≤ ej.te holds.

2). The notation seto f(e1,n) denotes the set{e1, ..., en}.

3). The notation seto f(−→e1,n) denotes the set{e1, ..., en} with e1.ts≤ e1.te < ... <

en.ts≤ en.te.

4). The notationΠE1,n denotes the cross product of event histories from E1 to

En. Namely,ΠE1,n[Hw] = E1[Hw]× E2[Hw]× ... Ei[Hw]× ... × En[Hw].

5). We use the notation <P1(e1), ... , Pn(en)> to refer to a set of simple predi-

cates applied to event instances e1, . . . , enrespectively. For ease of use, we

5.1. INTRODUCTION 92

Operator Semantics

Definition 12 Generating expressions return event histories while boolean expres-

sions return boolean values. ! Exp[Hw] = T iff Exp[Hw] = /0. ∃ Exp[Hw] = T iff

Exp[Hw]̸= /0.

Definition 13 [SEQ operator]. SEQ specifies a particular order in which the

event instances of interest e1, e2,..., enmust occur in order to correspond to a valid

match. The event instances that satisfy specified time ordering and predicates are returned. ΠE1,n[Hw] andP are denoted in Section 5.1.2. The meaning of a SEQ

expression (with boolean expressions) can be defined recursively in terms of the meanings of the subexpressions. Namely, in Equation 5.3 below, for 1 < i < n, Ei

is a primitive event type.

SEQ(E1e1, E2e2, ..., Eiei, . . . , Enen,P)[Hw]

={seto f(−→e1,n)|(−→e1,n∈ ΠE1,n[Hw])∧ (P == true)}.

(5.3)

Example 17 Given SEQ(Recycle r, Washing w) and H3={r1, w2, w3}, SEQ(Recycle r, Washing w)[H3] generates 2 event histories: {r1, w2} and {r1, w3}.

Definition 14 SEQ with Negation !. Equation 5.4 below defines the SEQ opera-

tor with negation in the middle of a list of event types. We first identify{e1,..., ei,

ei+1,..., en} matching the generating event expression satisfying associated predi-

5.1. INTRODUCTION 93

SEQ(E1e1, ..., Eiei, !X , Ei+1ei+1, ..., Enen,P)[Hw]

={seto f(−→e1,n)|−→e1,n∈ (ΠE1,n[Hw])∧ (P == true)

∧ X[H[ei.te, ei+1.ts]] =/0}.

(5.4)

SEQ(E1e1 ,..., Ei ei, ! X , Ei+1 ei+1,..., En en, P)[Hw] is the set of all those

sequences{e1,..., ei, ei+1,..., en} such that

(i) The time ordered event set{e1,..., ei, ei+1,..., en} is in SEQ(E1e1 ,..., Eiei,

Ei+1ei+1,..., Enen,P)[Hw], and

(ii) X [H’] is empty, where H’ is the sub-history of [Hw] determined by the end-

time of eiand the start time of ei+1if Eiand Ei+1are positive primitive event types.

Otherwise, the left bound of H’ is determined by the end-time of the event instance of the first positive event type from Ei, Ei−1 ,..., to E1. If Ei, Ei−1 ,..., and E1are

all negative, the left bound of H’ is the same as the left bound of Hw. Similarly,

the right bound of H’ is determined by the start-time of the event instance of the first positive event type from Ei+1, Ei+2,..., to En. If Ei+1, Ei+2,..., and En are all

negative, the right bound of H’ is the same as the right bound of Hw.

Multiple negations could exist inside a SEQ. Negation could equally exist at the start or the end of the SEQ operator. Given a Hw, if negation exists at the

start, the non-existence left time bound would be min(en.te−w, Hw.ts). Similarly, if

negation exists at the end, the non-existence right time bound would be max(e1.ts + w, Hw.te). If negations are specified at both the start and the end of the SEQ

operator, no negation match exists in either scopes of size w. Namely, the non- existence left time bound would be min(en.te− w, Hw.ts) and the right time bound

5.1. INTRODUCTION 94

would be max(e1.ts + w, Hw.te).

If the specified events of the boolean expression ! E don’t exist in the stream at the specified location, then we find a match for the event expression with nega- tion(s). Multiple boolean expression ! E could also be specified in the SEQ op- erator. For example SEQ(Washing w, ! (Sharpening s, s.id = 1), Disinfection d, ! (Checking c, c.id = 2)).

Definition 15 SEQ with Exists ∃. Equation 5.5 defines the SEQ operator with

∃ before event expressions. We first identify {e1 ,..., ei, ei+1 ,..., en} matching

the generating event expression satisfying associated predicates. We then verify the existence of X instances between ei and ei+1events of each candidate match

history.

SEQ(E1e1, ..., Eiei,∃X,Ei+1ei+1, ..., Enen,P)[Hw]

={seto f(−→e1,n)|−→e1,n∈ ΠE1,n[Hw]∧ (P == true) ∧ X[H[ei.te, ei+i.ts]]̸= /0}.

(5.5)

SEQ(E1e1 ,..., Ei ei,∃ X , Ei+1ei+1,..., En en,P)[Hw] are the sets{e1,..., ei,

ei+1,..., en} such that

(i) The time ordered event instance set{e1,..., ei, ei+1,..., en} is in SEQ(E1e1

,..., Eiei, Ei+1ei+1,..., Enen,P)[Hw], and

(ii) X [H’] is not empty, where H’ is the sub-history of [Hw] determined by the

end-time of ei and the start time of ei+1if Ei and Ei+1are positive primitive event

types. Otherwise, the left bound of H’ is determined by the end-time of the event instance of the first positive event type from Ei, Ei−1,..., to E1. If Ei, Ei−1,..., and E1

5.1. INTRODUCTION 95

are all negative, the left bound of H’ is the same as the left bound of Hw. Similarly,

the right bound of H’ is determined by the start-time of the event instance of the first positive event type from Ei+1, Ei+2,..., to En. If Ei+1, Ei+1,..., and En are all

negative, the right bound of H’ is the same as the right bound of Hw.

Definition 16 [AND operator]. We don’t require event timestamp ordering among

e1, e2,..., enin{e1, e2, ..., en} in Equation 5.6. The meaning of a AND expression

(with boolean expressions) can be defined recursively in terms of the meanings of the subexpressions. Namely, in Equation 5.6 below, for 1 < i < n, Eiis a primitive

event type.

AND(E1e1, E2e2, ...Enen,P)[Hw]

={seto f(e1,n)|(seto f(e1,n)∈ ΠE1,n[Hw])∧ (P == true)}.

(5.6)

Example 18 Given AND(Recycle r, Washing w) and the partial input stream{w1,

r2, w3} within the window. Then {{r2, w1}, {r2, w3}} is generated.

Definition 17 AND with Negation ! Equation 5.7 defines the AND operator with

negation. Negation ! X works like a filter. Each AND candidate result is returned if X [Hw] =/0.

AND(E1e1, ..., Eiei, !X , Ei+1ei+1, ..., Enen,P})[Hw]

={seto f(e1,n)|seto f(e1,n)∈ ΠE1,n[Hw]∧ (P == true) ∧ X[Hw] = /0}.

(5.7)

5.1. INTRODUCTION 96

{e1,..., ei, ei+1,..., en} such that

(i) {e1 ,..., ei, ei+1 ,..., en} is in AND(E1 e1 ,..., Ei ei, Ei+1 ei+1 ,..., En en ,

P)[Hw], and

(ii) X [Hw] is nonempty,

Multiple negation could exist in AND. Positions of ! E in AND doesn’t matter. AND operator must contain at least one positive expression.

Example 19 Given AND(Recycle r, Washing w, ! Checking c) and the partial input stream{c1, w2, r3}, no results are generated due to the existence of the event c1 Checking within the window constraint history.

Definition 18 AND with Exists∃. Equation 5.8 defines the AND operator with

∃. ∃ X works like a filter. Each AND candidate result is returned if X[Hw] is not

empty.

AND(E1e1, ..., Eiei,∃X,Ei+1ei+1, ..., Enen,P)[Hw]

={seto f(e1,n)|seto f(e1,n)∈ ΠE1,n[Hw]∧ (P == true) ∧ X[Hw]̸= /0}.

(5.8)

AND(E1 e1 ,..., Ei ei,∃ X , Ei+1ei+1,..., Enen,P)[Hw] is the set of all those

{e1,..., ei, ei+1,..., en} such that

(i) {e1 ,..., ei, ei+1 ,..., en} is in AND(E1 e1 ,..., Ei ei, Ei+1 ei+1 ,..., En en ,

P)[Hw], and

(ii) X [Hw] is nonempty.

Definition 19 [OR operator]. Formally, the set-operator OR is defined as follows.

5.1. INTRODUCTION 97

OR(E1e1, ..., Enen,P)[Hw]

={{e1}|{e1} ∈ E1[Hw]∧ (P1(e1) == true)} ∪ ...∪ {{en}|{en} ∈ En[Hw]∧ (Pn(en) == true)}

(5.9)

OR with Boolean Expressions.

Boolean expressions including ! E and∃ E are not allowed in the OR operator

as OR connects generating expressions.

Example 20 Assume that the query Q2= OR(Checking, Sharpening, Checking.insType

= “scalpels”; Sharpening.insID = 15)[H4]. The event history H ={c1, c2, c6, s8} where c1.insType = “forceps”, c2.insType = “scalpels”, c6.insType = “scalpels” and s8.insID = 15. Then Q2returns a result history{{c6}, {s8}}.