1. BigData
Semantic Approach to
Big Data and Event Processing
Walk through Streaming
Technologies: EPL
Riccardo Tommasini
PhD Student Politecnico di Milano
riccardo.tommasini@polimi.it
11. BigData1
1
EPL Statements are
registered into Esper
and continuously
executed as the live
data stream are
pushed through
Event Streams/Complex Event Processing: EPL
Event Processing Language (EPL)
Continuous
Query
Answering
Complex
Pattern Matching
(causality
relationship)
12. BigData1
2
• Push Based
• Data tuple from sensors,
trace files etc.
• Push Based
• Continuously executed
against incoming events
• Receive data tuples from
queries
• Push data tuple to other
queries
• Receive processed tuples
EPL
Query
Subscriber
Source
Listener
EPL ConAnuous Query Processing Model
13. BigData1
3
• Sources act as input
• EPL Queries Integrate
sources
• Listener propagates query
results
• Subscribers act as output
EPL Query Model can be represented as a graph
Graph nodes are functional
components, manually
connect by the data stream.
EPL ConAnuous Query Processing Model
15. BigData1
5
We starts with the demo time
https://github.com/riccardotommasini/esper-tutorial
http://esper-epl-tryout.appspot.com/epltryout/mainform.html
ONLINE VERSION
Java Code Data for the running example
DEMO
16. BigData16
Count the number of fires detected using a set of smoke and
temperature sensors in the last 10 minutes
Request
Events
CondiAon
• Smoke Event: String sensor, boolean state
• Temperature Event: String sensor, double temperature
• Fire Event: String sensor, boolean smoke, double temperature
Fire: The same sensor detects smoke followed by temperature >
50°C
Running Example
22. BigData22
[insert into insert_into_def]
select select_list
from stream_def [as name] [, stream_def [as name]]
[,...]
[where search_conditions]
[group by grouping_expression_list]
[having grouping_search_conditions]
[output output_specification]
[order by order_by_expression_list]
[limit num_rows]
• Similar to SQL (select,
where)
• views are used inset of tables
EPL: Query RegistraAon
23. BigData23
@Name(‘Q0’) select *
from TemperatureSensorEvent
where temperature > 50;
@Name(‘Q1’) select avg(temperature)
from TemperatureSensorEvent;
Stream Lookup
Aggregate
EPL Queries: Examples
24. BigData24
• Similar to SQL tables
• define data available for querying and filtering
• sorting, aggregation, grouping operation are
possible
• usually represented as windows over the
streams of events
EPL: Views
25. BigData25
Type Syntax Description
Logical Sliding win:time(time period) Sliding time window extending the
specified time interval into the past
Logical Tumbling win:time_batch(time
period)
Tumbling window that batches
events and releases them every
specified time interval, with flow
control options
Physical Sliding win:length(size) Sliding length window extending
the specified number of events into
the past
Physical Tumbling win:length_batch(size) Tumbling window that batches
events and releases them when a
given minimum number is has been
collected
EPL: Statements and Windows
36. BigData36
• Looking for a pattern of events over
the incoming data streams
• pattern can be temporal as well as
physical
• it’s implemented via finite states
machine
EPL: Event PaSern Matching
41. BigData
Simple Example: every (A -> B)
• PaSern
– every ( A -> B )
• Events
– A1 B1 C1 B2 A2 D1 A3 B3 E1 A4 F1 B4
• Results
– Detect an A event followed by a B event. At the Ame
when B occurs the paSern matches, then the paSern
matcher restarts and looks for the next A event.
1. Matches on B1 for combinaAon {A1 , B1}
2. Matches on B3 for combinaAon {A2 , B3}
3. Matches on B4 for combinaAon {A4 , B4}
41Stream & Complex Event Processing - Introduction
42. BigData
• PaSern
– every A -> B
• Events
– A1 B1 C1 B2 A2 D1 A3 B3 E1 A4 F1 B4
• Results
– The paSern fires for every A event followed by a B
event.
1. Matches on B1 for combinaAon {A1 , B1}
2. Matches on B3 for combinaAon {A2 , B3} and {A3 , B3}
3. Matches on B4 for combinaAon {A4 , B4}
42Stream & Complex Event Processing - Introduction
Simple Example: every A -> B
43. BigData
• PaSern
– A -> every B
• Events
– A1 B1 C1 B2 A2 D1 A3 B3 E1 A4 F1 B4
• Results
– The paSern fires for an A event followed by every B
event.
1. Matches on B1 for combinaAon {A1 , B1}
2. Matches on B2 for combinaAon {A1 , B2}
3. Matches on B3 for combinaAon {A1 , B3}
4. Matches on B4 for combinaAon {A1 , B4}
43Stream & Complex Event Processing - Introduction
Simple Example: A -> every B
44. BigData
• PaSern
– every A -> every B
• Events
– A1 B1 C1 B2 A2 D1 A3 B3 E1 A4 F1 B4
• Results
– The paSern fires for every A event followed by every B
event.
1. Matches on B1 for combinaAon {A1 , B1}
2. Matches on B2 for combinaAon {A1 , B2}
3. Matches on B3 for combinaAon {A1 , B3}, {A2 , B3} and {A3 , B3}
4. Matches on B4 for combinaAon {A1 , B4}, {A2 , B4}, {A3 , B4}
and {A4 , B4}
44Stream & Complex Event Processing - Introduction
Simple Example: every A -> every B
46. BigData
• Events
– A1 A2 B1
• PaSern
– every A -> B
• Results
– {A1 , B1} and {A2 , B1}
• Events
– A1 A2 B1
• PaSern
– every A -> (B and not A)
• Results
– {A2 , B1}
– The and not operators
cause the sub-
expression looking for
{A1, B?} to end when A2
arrives.
46Stream & Complex Event Processing - Introduction
Guards Example 1
47. BigData
• Events
– A1 received at to+ 1 sec
– A2 received at to+ 3 sec
– B1 received at to+ 4 sec
• PaSern
– every A -> B
• Results
– {A1 , B1} and {A2 , B1}
• Events
– A1 received at to+ 1 sec
– A2 received at to+ 2 sec
– B1 received at to+ 3 sec
• PaSern
– every A -> (B where Amer:within(2 sec) )
• Results
– {A2 , B1}
– The where 9mer:within operators cause
the sub-expression looking for {A1, B?}
to end aker 2 seconds.
47Stream & Complex Event Processing - Introduction
Guards Example 2
53. BigData53
package us.wsu.knoesis.tutorial.events;
public class FireEvent {
private String sensor;
private boolean smoke;
}• Getter and Setter naming
convention are relevant to access
parameter form EPL
• the construct must be defined as
well
• toString is used to represent
display the event, consider
redefinition
Event DeclaraAon Java POJO