SlideShare a Scribd company logo
Event Stream
Event Stream
SYLVAIN HALLÉ
Université du Québec
à Chicoutimi
SYLVAIN HALLÉ
Université du Québec
à Chicoutimi
Processing
Processing
with
with
CRSNG
NSERC
PART 1
PART 1
INTRODUCTION
INTRODUCTION
What is an event?
$
A unit of data produced by the execu�on or the
observa�on of a "system".
$$$$$
$$$$$
$$$$$
update of a stock price
sensor reading
link
state of a video game
user visi�ng a web page
parcel being delivered
/
move in a chess game
...and an event stream?
An ordered sequence of events of a given type
...
...and an event stream?
An ordered sequence of events of a given type
...
...
...and an event stream?
An ordered sequence of events of a given type
...
...
...
...and an event stream?
An ordered sequence of events of a given type
...
...
...
...
...and an event stream?
An ordered sequence of events of a given type
...
...
...
...
called a log
when stored
for later use
...and an event stream?
An ordered sequence of events of a given type
...
...
...
...
called a log
when stored
for later use
Events can be
composite: ...
Event stream processing
A calcula�on done on an event stream
Event stream processing
A calcula�on done on an event stream
what is the maximum
temperature of the last
100 readings?
Event stream processing
A calcula�on done on an event stream
what is the maximum
temperature of the last
100 readings?
who is the employee
who delivered the most
parcels?
Event stream processing
A calcula�on done on an event stream
what is the maximum
temperature of the last
100 readings?
who is the employee
who delivered the most
parcels?
is there a user who
accessed page A from
page B?
Event stream processing
A calcula�on done on an event stream
what is the maximum
temperature of the last
100 readings?
who is the employee
who delivered the most
parcels?
is there a user who
accessed page A from
page B?
$ has the stock decreased
three days in a row?
Event stream processing
A calcula�on done on an event stream
what is the maximum
temperature of the last
100 readings?
who is the employee
who delivered the most
parcels?
is there a user who
accessed page A from
page B?
$ has the stock decreased
three days in a row?
has Mario ever collided
with an enemy during
a jump?
Event stream processing
A calcula�on done on an event stream
what is the maximum
temperature of the last
100 readings?
who is the employee
who delivered the most
parcels?
is there a user who
accessed page A from
page B?
$ has the stock decreased
three days in a row?
has Mario ever collided
with an enemy during
a jump?
what is the move
taken most frequently
a�er e2 e4?
Event stream processing
A calcula�on done on an event stream
Similar to a database query, but:
o�en concerned with the order of occurrence
result is produced incrementally
what is the maximum
temperature of the last
100 readings?
who is the employee
who delivered the most
parcels?
is there a user who
accessed page A from
page B?
$ has the stock decreased
three days in a row?
has Mario ever collided
with an enemy during
a jump?
what is the move
taken most frequently
a�er e2 e4?
Stream vs. batch mode
BATCH STREAM
higher performance
one-shot opera�on
offline results
incremental calcula�on
stateful
online results
Storing streams
Streams can be stored...
in a text file (JSON,
XML, CSV, etc.)
A B C
3.14
in a spreadsheet
in a database you don't store
them!
+
The right tool...
...for the right task
The right tool...
...for the right task
The right tool...
...for the right task
A B C
3.14
The right tool...
...for the right task
A B C
3.14
The right tool...
...for the right task
A B C
3.14
The right tool...
...for the right task
A B C
3.14
The right tool...
...for the right task
A B C
3.14
The right tool...
...for the right task
A B C
3.14
$ bash
The right tool...
...for the right task
A B C
3.14
$ bash
The right tool...
...for the right task
A B C
3.14
$ bash
The right tool...
...for the right task
A B C
3.14
(One example of this later)
$ bash
PART 2
PART 2
FUNDAMENTALS OF
BEEPBEEP
FUNDAMENTALS OF
BEEPBEEP
Introducing
BeepBeep is an open source library wri�en in Java
and developed at since 2015.
It can be used to perform stream processing in
any language that uses the JVM:
this presenta�on
h�ps://liflab.github.io/beepbeep-3
Introducing
A complete textbook is available under an open
access license
research papers
and case studies
downloads
Best Paper
Award
1000
1000
20
20
1
1
h�ps://bit.ly/beepbeep-book
Presses de l'Université du Québec
Design principles
Simple elementary building blocks
zero-configura�on
Design principles
Simple elementary building blocks
zero-configura�on
Intui�ve simple mental model
few rules of opera�on
Design principles
Simple elementary building blocks
zero-configura�on
Intui�ve simple mental model
few rules of opera�on
Flexible composi�on
dozens of extensions
Design principles
Simple elementary building blocks
zero-configura�on
Intui�ve simple mental model
few rules of opera�on
Flexible composi�on
dozens of extensions
Lightweight low system requirements
core < 300 kb
Events
2
3
4
π abc
3 8 a
3 8 a
2 6 c
An event can be any (Java) object:
numbers Booleans strings tuples (key-value)
Events
2
3
4
π abc
3 8 a
3 8 a
2 6 c
An event can be any (Java) object:
numbers Booleans strings tuples (key-value)
+
⊇?
...but also...
sets func�ons plots colors
chess
moves
. . .
Processor
A processor is a computa�on unit that ingests
input events and produces output events
P
Processor
A processor is a computa�on unit that ingests
input events and produces output events
P
processor
Processor
A processor is a computa�on unit that ingests
input events and produces output events
P
processor
input pipe
Processor
A processor is a computa�on unit that ingests
input events and produces output events
P
processor
input pipe
event
Processor
A processor is a computa�on unit that ingests
input events and produces output events
P
processor
input pipe
event
output pipe
Arity
Some processors have more than one input pipe...
"2:1 processor"
Arity
Some processors have more than one input pipe...
"2:1 processor"
"1:2 processor"
...others can have more than one output pipe
A source is a processor with no input pipe
Sources and sinks
3 1 4
4 1 5 9 2
queue source keyboard
A source is a processor with no input pipe
Sources and sinks
3 1 4
4 1 5 9 2
queue source keyboard
A sink is a processor with no output pipe
queue sink print black hole
A processor can have pipes with different types:
Pipe types
Each pipe receives / produces events of a specific
type. Color conven�ons are used for common types:
Booleans strings tuples
tables blobs
maps/sets
numbers
Basic processors
A set of "core" processors that perform elementary
opera�ons on streams.
n
P
{
f
f n n
Σ
f
n
k
n
fork filter window slice turn into
apply decimate trim cumulate prefix
f
P
ApplyFunction
Applies a func�on to events
of the input
f
f
f
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
square root
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
get a�ribute "A" from a tuple
tuple
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
f
4 0 21 3 1 0
-2 ⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
>
1 0
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
f
4 0 21 3 1 0
-2 ⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
>
1 0
constant 0
the first input pipe
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
f
4 0 21 3 1 0
-2 ⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
>
1 0
constant 0
the first input pipe
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
√
4 9 16 1 9 1
25 2 3 1 3 1
4 5
f a b z
A
3
8
a
A B C
0
5
b
A B C
1
2
z
A B C
f
4 0 21 3 1 0
-2 ⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
>
1 0
constant 0
the first input pipe
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
f
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
A B D F G
C E
a B d f G
c E
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
f
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
A B D F G
C E
a B d f G
c E
if-then-else
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
f
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
A B D F G
C E
a B d f G
c E
ApplyFunction
Applies a func�on to events
of the input
f
f
f
f
+
4 9 16 1 9 1
25
4 0 21 3 1 0
-2 8 9 37 1
23
4 10
f
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
A B D F G
C E
a B d f G
c E
TurnInto
Turns every event into
k
k
TurnInto
Turns every event into
k
k
3 1 1 9 2
4 5 0 0 0 0 0 0
0 0
TurnInto
Turns every event into
k
k
3 1 1 9 2
4 5 0 0 0 0 0 0
0 0
TurnInto
Turns every event into
k
k
3 1 1 9 2
4 5 0 0 0 0 0 0
0 0
TurnInto
Turns every event into
k
k
3 1 1 9 2
4 5 0 0 0 0 0 0
0 0
TurnInto
Turns every event into
k
k
3 1 1 9 2
4 5 0 0 0 0 0 0
0 0
TurnInto
Turns every event into
k
k
3 1 1 9 2
4 5 0 0 0 0 0 0
0 0
a a a a a a
a a
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
CountDecimate
Keeps one event every
n
n
CountDecimate
Keeps one event every
n
n
a b d f g
c e a c g
e
2
CountDecimate
Keeps one event every
n
n
a b d f g
c e a c g
e
2
CountDecimate
Keeps one event every
n
n
a b d f g
c e a c g
e
2
CountDecimate
Keeps one event every
n
n
a b d f g
c e a c g
e
2
CountDecimate
Keeps one event every
n
n
a b d f g
c e a c g
e
2
Trim
Discards the first events
n
n
Trim
Discards the first events
n
n
3 1 1 9 2
4 5 1 5 2
9
3
Trim
Discards the first events
n
n
3 1 1 9 2
4 5 1 5 2
9
3
Trim
Discards the first events
n
n
3 1 1 9 2
4 5 1 5 2
9
3
Trim
Discards the first events
n
n
3 1 1 9 2
4 5 1 5 2
9
3
Trim
Discards the first events
n
n
3 1 1 9 2
4 5 1 5 2
9
3
Fork
Replicates the input stream into
each output pipe (>1)
Fork
Replicates the input stream into
each output pipe (>1)
3 1 1 9 2
4 5
3 1 1 9 2
4 5
3 1 1 9 2
4 5
Filter
Discards events from a stream
based on a control signal
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
Filter
Discards events from a stream
based on a control signal
⊤ ⊥ ⊤ ⊤ ⊥
⊤ ⊥
a b d f g
c e
a c f
d
The Boolean stream does not need to be related
to the filtered stream
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
+
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
+
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
+
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
+
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Σ
-∞
max
3 1 1 9 2
4 5 3 3 4
4 5 9 9
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Σ
-∞
max
3 1 1 9 2
4 5 3 3 4
4 5 9 9
max
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Σ
-∞
max
3 1 1 9 2
4 5 3 3 4
4 5 9 9
max
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Σ
-∞
max
3 1 1 9 2
4 5 3 3 4
4 5 9 9
max
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Σ
-∞
max
3 1 1 9 2
4 5 3 3 4
4 5 9 9
max of all
events
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Σ
-∞
max
3 1 1 9 2
4 5 3 3 4
4 5 9 9
max of all
events
⊥ ⊥ ⊥ ⊥ ⊤
⊥ ⊤ ⊥ ⊥ ⊥ ⊤ ⊤
⊥ ⊤
Σ
⊥
∧
Cumulate
Applies func�on to current
input and last output, star�ng with
value
f
n
Σ
f
n
3 1 1 9 2
4 5 3 4 9
8 14
Σ
0
+
23 25
sum of all
events
Σ
-∞
max
3 1 1 9 2
4 5 3 3 4
4 5 9 9
max of all
events
⊥ ⊥ ⊥ ⊥ ⊤
⊥ ⊤ ⊥ ⊥ ⊥ ⊤ ⊤
⊥ ⊤
Σ
⊥
∧
have we seen
⊤ so far?
Window
Runs processor on each
window of successive inputs
and returns the last event it produces
n
n
n
P
{
P
Window
Runs processor on each
window of successive inputs
and returns the last event it produces
n
n
n
P
{
P
n
3
{
Σ
0
+
3 1 1 9 2
4 5 8 6 10 15 16
Window
Runs processor on each
window of successive inputs
and returns the last event it produces
n
n
n
P
{
P
n
3
{
Σ
0
+
3 1 1 9 2
4 5 8 6 10 15 16
3 1 4 3 4 8
Window
Runs processor on each
window of successive inputs
and returns the last event it produces
n
n
n
P
{
P
n
3
{
Σ
0
+
3 1 1 9 2
4 5 8 6 10 15 16
1 4 1 1 5 6
Window
Runs processor on each
window of successive inputs
and returns the last event it produces
n
n
n
P
{
P
n
3
{
Σ
0
+
3 1 1 9 2
4 5 8 6 10 15 16
4 1 5 4 5 10
Window
Runs processor on each
window of successive inputs
and returns the last event it produces
n
n
n
P
{
P
n
3
{
Σ
0
+
3 1 1 9 2
4 5 8 6 10 15 16
1 5 9 1 6 15
Window
Runs processor on each
window of successive inputs
and returns the last event it produces
n
n
n
P
{
P
n
3
{
Σ
0
+
3 1 1 9 2
4 5 8 6 10 15 16
sum of 3 successive events
Window
Note that can be any
processor (not limited to
aggrega�ons or numerical inputs)
n
n
P
{
P
Window
Note that can be any
processor (not limited to
aggrega�ons or numerical inputs)
n
n
P
{
P
n
3
{
Σ
+
n
4
{
Σ
0
⊥
⊥ ⊤ ⊥ ⊥ ⊤
⊥ ⊥
∧
⊤ ⊤ ⊤
⊥
Window
Note that can be any
processor (not limited to
aggrega�ons or numerical inputs)
n
n
P
{
P
⊥ ⊤
⊥ ⊤ ⊤ ⊤
⊥ ⊤
n
3
{
Σ
+
n
4
{
Σ
0
⊥
⊥ ⊤ ⊥ ⊥ ⊤
⊥ ⊥
∧
⊤ ⊤ ⊤
⊥
Window
Note that can be any
processor (not limited to
aggrega�ons or numerical inputs)
n
n
P
{
P
⊥ ⊥
⊤ ⊥ ⊤ ⊤
⊤ ⊤
n
3
{
Σ
+
n
4
{
Σ
0
⊥
⊥ ⊤ ⊥ ⊥ ⊤
⊥ ⊥
∧
⊤ ⊤ ⊤
⊥
Window
Note that can be any
processor (not limited to
aggrega�ons or numerical inputs)
n
n
P
{
P
⊥ ⊥
⊥ ⊥ ⊥ ⊥
⊥ ⊥
n
3
{
Σ
+
n
4
{
Σ
0
⊥
⊥ ⊤ ⊥ ⊥ ⊤
⊥ ⊥
∧
⊤ ⊤ ⊤
⊥
Window
Note that can be any
processor (not limited to
aggrega�ons or numerical inputs)
n
n
P
{
P
⊥ ⊤
⊥ ⊥ ⊥ ⊤
⊥ ⊥
n
3
{
Σ
+
n
4
{
Σ
0
⊥
⊥ ⊤ ⊥ ⊥ ⊤
⊥ ⊥
∧
⊤ ⊤ ⊤
⊥
Window
Note that can be any
processor (not limited to
aggrega�ons or numerical inputs)
n
n
P
{
P
true if a window of 4 events
contains at least one ⊤
n
3
{
Σ
+
n
4
{
Σ
0
⊥
⊥ ⊤ ⊥ ⊥ ⊤
⊥ ⊥
∧
⊤ ⊤ ⊤
⊥
Pipelines
Complex calcula�ons can be achieved through
composi�on
Pipelines
Complex calcula�ons can be achieved through
composi�on
passing the output of a processor
to the input of another
Pipelines
Complex calcula�ons can be achieved through
composi�on
passing the output of a processor
to the input of another
Pipelines
Complex calcula�ons can be achieved through
composi�on
passing the output of a processor
to the input of another
Pipelines
Complex calcula�ons can be achieved through
composi�on
passing the output of a processor
to the input of another
Doing so creates processor chains or "pipelines".
Example:
2
f
x2
Pipelines
Complex calcula�ons can be achieved through
composi�on
passing the output of a processor
to the input of another
Doing so creates processor chains or "pipelines".
Example:
2
f
x2
2
1 3 4 5 9
1 25
Pipelines
Complex calcula�ons can be achieved through
composi�on
passing the output of a processor
to the input of another
Doing so creates processor chains or "pipelines".
Example:
2
f
x2
2
1 3 4 5 9
1 25
the square of every
other number
Pipelines
Pipelines are one-way: events flow from outputs
to inputs
Pipelines
Any output can be connected to any input, as long
as they have the same type
Pipelines
Any output can be connected to any input, as long
as they have the same type
many types can occur in the same pipeline
A few examples
BeepBeep's textbook comes with 150+ illustrated
code examples (in Java) available online
h�ps://liflab.github.io/beepbeep-3-examples
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
1
3 2 6 3
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
1
3 2 6 3
4
3 6 12 15
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
1
3 2 6 3
4
3 6 12 15
2
1 3 4 5
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
1
3 2 6 3
4
3 6 12 15
2
1 3 4 5
2
3 2 3 3
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
1
3 2 6 3
4
3 6 12 15
2
1 3 4 5
2
3 2 3 3
the running average of the input stream
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
the running average
of the input stream
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
the running average
of the input stream
1
3 2 6 3 2 4 3 3
2 3
32
3 32
3 32
3
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
the running average
of the input stream
1
3 2 6 3 2 4 3 3
2 3
32
3 32
3 32
3
2
3 2
1
3 2
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
the running average
of the input stream
1
3 2 6 3 2 4 3 3
2 3
32
3 32
3 32
3
1
1 3
2
1 6
1
2
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
the running average
of the input stream
1
3 2 6 3 2 4 3 3
2 3
32
3 32
3 32
3
2
6
2 3 4 32
3
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
the running average
of the input stream
1
3 2 6 3 2 4 3 3
2 3
32
3 32
3 32
3
6
3
6 2 32
3
41
2
3
{
f
Σ
0
+
Σ
0
+
÷
1
What does this pipeline calculate?
A few examples
the running average
of the input stream
on each window of
3 successive events
1
3 2 6 3 2 4 3 3
2 3
32
3 32
3 32
3
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
read lines
from a file
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
split line into
word list
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
output each
word as an event
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
create a slice
for each word
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
count
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
keep last
event
What does this pipeline calculate?
A few examples
f
foo
1
Σ
0
+
the number of occurrences
of each word in a file
brown
fox
jumped
lazy
dog
quick
the
over
1
1
5
2
3
2
12
4
Slice
n
P
{
f
Splits an input stream into
sub-stream according to , and
runs on each sub-stream
P
f
Slice
n
P
{
f
Splits an input stream into
sub-stream according to , and
runs on each sub-stream
P
f
Example: mul�ple players rolling a dice
Slice
n
P
{
f
Splits an input stream into
sub-stream according to , and
runs on each sub-stream
P
f
Example: mul�ple players rolling a dice
Slice
n
P
{
f
Splits an input stream into
sub-stream according to , and
runs on each sub-stream
P
f
Example: mul�ple players rolling a dice
Slice
n
P
{
f
Suppose we have two func�ons
and to extract the contents
of a "dice event"
? ?
Slice
n
P
{
f
get the player get the dice value
? ?
Suppose we have two func�ons
and to extract the contents
of a "dice event"
? ?
Slice
n
P
{
f
n
{
?
f
?
Σ
0
+
Slice
n
P
{
f
n
{
?
f
?
Σ
0
+
for each player...
Slice
n
P
{
f
n
{
?
f
?
Σ
0
+
for each player...
get dice value
Slice
n
P
{
f
n
{
?
f
?
Σ
0
+
for each player...
get dice value sum
Slice
n
P
{
f
The output is a map that associates
each slice and the last event
produced by P
Slice
n
P
{
f
The output is a map that associates
each slice and the last event
produced by P
1
Slice
n
P
{
f
The output is a map that associates
each slice and the last event
produced by P
1
5
1
Slice
n
P
{
f
The output is a map that associates
each slice and the last event
produced by P
5
5
1
5
1
Slice
n
P
{
f
The output is a map that associates
each slice and the last event
produced by P
5
5
3
5
5
1
5
1
Slice
n
P
{
f
The output is a map that associates
each slice and the last event
produced by P
5
5
5
5
5
3
5
5
1
5
1
Slice
n
P
{
f
The output is a map that associates
each slice and the last event
produced by P
5
6
5
5
5
5
5
5
3
5
5
1
5
1
Slice
n
P
{
f
n
{
f
?
?
}
{
Slice
n
P
{
f
n
{
f
?
?
}
{
for each dice value...
Slice
n
P
{
f
n
{
f
?
?
}
{
for each dice value...
get player
Slice
n
P
{
f
n
{
f
?
?
}
{
for each dice value...
get player put into set
Slice
n
P
{
f
Slices correspond to dice values
Push vs. pull mode
The default state of a processor
is to sleep.
ZZ
Z
Push vs. pull mode
The default state of a processor
is to sleep.
ZZ
Z
It springs into ac�on when either:
Push vs. pull mode
The default state of a processor
is to sleep.
ZZ
Z
It springs into ac�on when either:
we give it a new input event to ingest
!
1
Push vs. pull mode
The default state of a processor
is to sleep.
ZZ
Z
It springs into ac�on when either:
! may in turn give events
to downstream
processors: push mode
we give it a new input event to ingest
1
Push vs. pull mode
The default state of a processor
is to sleep.
ZZ
Z
It springs into ac�on when either:
! may in turn give events
to downstream
processors: push mode
we give it a new input event to ingest
1
we ask it for new output events to produce
2
?
Push vs. pull mode
The default state of a processor
is to sleep.
ZZ
Z
It springs into ac�on when either:
! may in turn give events
to downstream
processors: push mode
we give it a new input event to ingest
1
we ask it for new output events to produce
2
may in turn ask events
to upstream
processors: pull mode
?
Pipelines
A pipeline is closed if either:
Pipelines
A pipeline is closed if either:
!
!
- all its downstream endpoints are sinks
Pipelines
A pipeline is closed if either:
- all its downstream endpoints are sinks
?
- all its upstream endpoints are sources
QueueSource
Outputs events from a queue
when pulled ( )
?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
4
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
9
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
16
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
1
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
9
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
1
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
QueueSource
Outputs events from a queue
when pulled ( )
?
4 9 16 1 9 1
25 ?
×
QueueSink
!
Accumulates pushed ( ) events
into a queue
QueueSink
!
Accumulates pushed ( ) events
into a queue
QueueSink
!
Accumulates pushed ( ) events
into a queue
!
4
QueueSink
!
Accumulates pushed ( ) events
into a queue
4
!
4
QueueSink
!
Accumulates pushed ( ) events
into a queue
4
QueueSink
!
Accumulates pushed ( ) events
into a queue
4
!
9
QueueSink
!
Accumulates pushed ( ) events
into a queue
9
4
!
9
QueueSink
!
Accumulates pushed ( ) events
into a queue
9
4
QueueSink
!
Accumulates pushed ( ) events
into a queue
9
4
!
16
QueueSink
!
Accumulates pushed ( ) events
into a queue
9 16
4
!
16
QueueSink
!
Accumulates pushed ( ) events
into a queue
9 16
4
QueueSink
!
Accumulates pushed ( ) events
into a queue
9 16
4
!
1
QueueSink
!
Accumulates pushed ( ) events
into a queue
9 16 1
4
!
1
Synchronous operation
Processors operate in a "lockstep" fashion
consume input events one at a �me
produce output events one at a �me
Synchronous operation
Processors operate in a "lockstep" fashion
consume input events one at a �me
produce output events one at a �me
Synchronous operation
Processors operate in a "lockstep" fashion
consume input events one at a �me
produce output events one at a �me
Synchronous operation
Processors operate in a "lockstep" fashion
consume input events one at a �me
produce output events one at a �me
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
3
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
3
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
2
3
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
3
2
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
5
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
1
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
1
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
7
1
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
1
7
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
8
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
4
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
4
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
1
4
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
4
1
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
5
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
1
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
1
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
8
1
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
1
8
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
9
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
5
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
?
5
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
?
×
5
3 1 1 9 2
f
+
4 5
2 7 8
1
Synchronous operation
Example in pull mode
5
×
ZZ
Z
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
When this is the case, it can produce an
output event...
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
When this is the case, it can produce an
output event... or more than one output event...
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
When this is the case, it can produce an
output event... or more than one output event...
or nothing at all
ZZ
Z
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
Otherwise, incoming events are stored into internal
buffers un�l they can be consumed.
ZZ
Z
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
Otherwise, incoming events are stored into internal
buffers un�l they can be consumed.
ZZ
Z
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
Otherwise, incoming events are stored into internal
buffers un�l they can be consumed.
ZZ
Z
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
Otherwise, incoming events are stored into internal
buffers un�l they can be consumed.
ZZ
Z
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
Otherwise, incoming events are stored into internal
buffers un�l they can be consumed.
ZZ
Z
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
Otherwise, incoming events are stored into internal
buffers un�l they can be consumed.
A processor needs an event in each input pipe
to execute a computa�on step.
Synchronous operation
Otherwise, incoming events are stored into internal
buffers un�l they can be consumed.
f
+
Synchronous operation
Example in push mode
f
+
Synchronous operation
Example in push mode
!
3
f
+
Synchronous operation
Example in push mode
3
f
+
Synchronous operation
Example in push mode
!
2
3
f
+
Synchronous operation
Example in push mode
3
2
f
+
Synchronous operation
Example in push mode
!
5
f
+
Synchronous operation
Example in push mode
5
f
+
Synchronous operation
Example in push mode
5
!
7
f
+
Synchronous operation
Example in push mode
5
7
f
+
Synchronous operation
Example in push mode
5
!
7
1
f
+
Synchronous operation
Example in push mode
5
7
1
f
+
Synchronous operation
Example in push mode
5
!
7
1
1
f
+
Synchronous operation
Example in push mode
5
1
1
7
f
+
Synchronous operation
Example in push mode
5
!
1
8
f
+
Synchronous operation
Example in push mode
5 8
1
f
+
Synchronous operation
Example in push mode
5 8
!
1
8
f
+
Synchronous operation
Example in push mode
5 8
1
8
f
+
Synchronous operation
Example in push mode
5 8
!
1
4
8
f
+
Synchronous operation
Example in push mode
5 8
8
4
1
f
+
Synchronous operation
Example in push mode
5 8
!
8
5
f
+
Synchronous operation
Example in push mode
5 8 5
8
f
+
Synchronous operation
Example in push mode
5 8 5
!
8
1
f
+
Synchronous operation
Example in push mode
5 8 5
1
8
f
+
Synchronous operation
Example in push mode
5 8 5
!
9
f
+
Synchronous operation
Example in push mode
5 8 5 9
f
+
Synchronous operation
Example in push mode
5 8 5 9
!
5
f
+
Synchronous operation
Example in push mode
5 8 5 9
5
f
+
Synchronous operation
Example in push mode
5 8 5 9
!
×
5
f
+
Synchronous operation
Example in push mode
5 8 5 9
!
5
×
f
+
Synchronous operation
Example in push mode
5 8 5 9 ×
5
BeepBeep programs
Crea�ng a BeepBeep program is made of 3 steps:
instan�a�ng the processors
1
connec�ng them
2
pushing/pulling events
3
Prerequisites
Java 8 (or higher)
Groovy 4.0 (or higher)
to run CLI scripts
"Hello world"
!
Hello world
@Grab("ca.uqac.lif.cep:beepbeep-3:0.11")
import ca.uqac.lif.cep.io.*
new Print() << "Hello world"
A simple program
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
Automa�cally downloads the library
from the Central Repository
and installs it locally
(zero-configura�on)
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
load BeepBeep
0
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
load BeepBeep
0
2
dc
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
sq = new ApplyFunction(Numbers.square)
load BeepBeep
0
2
f
x2
dc sq
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
sq = new ApplyFunction(Numbers.square)
pr = new Print()
load BeepBeep
0
2
f
x2
dc sq pr
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
sq = new ApplyFunction(Numbers.square)
pr = new Print()
load BeepBeep
instan�ate
processors
1
0
2
f
x2
dc sq pr
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
sq = new ApplyFunction(Numbers.square)
pr = new Print()
Connector.connect(dc, sq)
load BeepBeep
instan�ate
processors
1
0
2
f
x2
dc sq pr
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
sq = new ApplyFunction(Numbers.square)
pr = new Print()
Connector.connect(dc, sq)
Connector.connect(sq, pr)
load BeepBeep
instan�ate
processors
1
0
2
f
x2
dc sq pr
A simple program
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
sq = new ApplyFunction(Numbers.square)
pr = new Print()
Connector.connect(dc, sq)
Connector.connect(sq, pr)
load BeepBeep
instan�ate
processors
connect
1
2
0
2
f
x2
dc sq pr
A simple program
squares.gvy
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.io.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
dc = new CountDecimate(2)
sq = new ApplyFunction(Numbers.square)
pr = new Print()
Connector.connect(dc, sq)
Connector.connect(sq, pr)
load BeepBeep
instan�ate
processors
connect
1
2
0
2
f
x2
dc sq pr
Pipelines can be created using few lines of code
(1 per box / pipe)
A simple program
No installa�on required (@Grab)
No compila�on required: programs can be saved
to a text file and run immediately at the
command line*
*When using Groovy
This program does nothing ( ). It is missing
part : pushing / pulling events.
A simple program
3
ZZ
Z
This program does nothing ( ). It is missing
part : pushing / pulling events.
A simple program
3
ZZ
Z
Two objects can be used:
This program does nothing ( ). It is missing
part : pushing / pulling events.
A simple program
3
ZZ
Z
Two objects can be used:
Two objects can be used:
Pushable
!
reference to an
input pipe
used to push events
Pushable
!
This program does nothing ( ). It is missing
part : pushing / pulling events.
A simple program
3
ZZ
Z
Two objects can be used:
Two objects can be used:
Pushable
!
reference to an
input pipe
used to push events
Pushable
! vs.
Pullable
?
reference to an
output pipe
used to pull events
vs.
Pullable
?
A simple program (cont'd.)
2
f
x2
dc sq pr
A simple program (cont'd.)
2
f
x2
dc sq pr
...
p = dc.getPushableInput()
p
A simple program (cont'd.)
2
f
x2
dc sq pr
...
p = dc.getPushableInput()
p
2
1 3 4 5
p.push(1)
p.push(2)
p.push(3)
p.push(4)
p.push(5)
A simple program (cont'd.)
2
f
x2
dc sq pr
...
p = dc.getPushableInput()
p
2
1 3 4 5
p.push(1)
p.push(2)
p.push(3)
p.push(4)
p.push(5)
push events
3
At the command prompt:
A simple program (cont'd.)
At the command prompt:
A simple program (cont'd.)
$ groovy squares.gvy
At the command prompt:
A simple program (cont'd.)
$ groovy squares.gvy
1,9,25
Another example
addition.gvy
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
A = new Fork()
B = new CountDecimate(3)
C = new ApplyFunction(Numbers.addition)
Connector.connect(A, 0, B, 0)
Connector.connect(B, 0, C, 0)
Connector.connect(A, 1, C, 1)
3
f
+
A
B
C
0
When a processor has
more than one input
or output pipe, the index
must be specified
1
0
1
0 0
@Grab("io.github.liflab:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
A = new Fork()
B = new CountDecimate(3)
C = new ApplyFunction(Numbers.addition)
Connector.connect(A, 0, B, 0)
Connector.connect(B, 0, C, 0)
Connector.connect(A, 1, C, 1)
Another example
addition.gvy
3
f
+
A
B
C
Syntactical shortcuts
Pipelines wri�en in Groovy can be shortened.
Syntactical shortcuts
Pipelines wri�en in Groovy can be shortened.
Connector.connect(A, B) A | B
Syntactical shortcuts
Pipelines wri�en in Groovy can be shortened.
Connector.connect(A, B) A | B
Connector.connect(A, x, B, y) A[x] | B[y]
Syntactical shortcuts
Pipelines wri�en in Groovy can be shortened.
Connector.connect(A, B) A | B
Connector.connect(A, x, B, y) A[x] | B[y]
The | connec�ve returns the last processor of the
chain
Syntactical shortcuts
Pipelines wri�en in Groovy can be shortened.
Connector.connect(A, B) A | B
Connector.connect(A, x, B, y) A[x] | B[y]
The | connec�ve returns the last processor of the
chain
Connector.connect(A, B)
Connector.connect(B, C)
p = C
p = A | B | C
Syntactical shortcuts
Pipelines wri�en in Groovy can be shortened.
Connector.connect(A, B) A | B
Connector.connect(A, x, B, y) A[x] | B[y]
The | connec�ve returns the last processor of the
chain
Connector.connect(A, B)
Connector.connect(B, C)
p = C
p = A | B | C
Pushable objects do not need to be explicitly
obtained:
Syntactical shortcuts
Pipelines wri�en in Groovy can be shortened.
Connector.connect(A, B) A | B
Connector.connect(A, x, B, y) A[x] | B[y]
The | connec�ve returns the last processor of the
chain
Connector.connect(A, B)
Connector.connect(B, C)
p = C
p = A | B | C
Pushable objects do not need to be explicitly
obtained:
p = proc.getPushableInput()
p.push(x)
proc << x
Syntactical shortcuts
3
f
+
A
B
C
@Grab("ca.uqac.lif.cep:beepbeep-3:0.11")
import ca.uqac.lif.cep.Connector
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
A = new Fork()
B = new CountDecimate(3)
C = new ApplyFunction(Numbers.addition)
Connector.connect(A, 0, B, 0)
Connector.connect(B, 0, C, 0)
Connector.connect(A, 1, C, 1)
p = A.getPushableInput()
p.push(0)
p.push(1)
Syntactical shortcuts
3
f
+
A
B
C
@Grab("ca.uqac.lif.cep:beepbeep-3:0.11")
import ca.uqac.lif.cep.functions.*
import ca.uqac.lif.cep.tmf.*
import ca.uqac.lif.cep.util.*
A = new Fork()
C = A[0] | new CountDecimate(3) |
new ApplyFunction(Numbers.addition)
A[1] | C[1]
A << 0 << 1
Other processors
BeepBeep provides many other processors and
func�ons. Some examples:
SELECT * FROM foo
http://...
↑
freeze an
event
k
repeat each
event
k
insert an
event
read from an
HTTP request
read from a
DB query
serialize an
event
Other processors
BeepBeep provides many other processors and
func�ons. Some examples:
P
1 P
2 P
3
, ,
TANK
k
Moore machine detect peaks
pack events
tank pump splice sources
PART 3
PART 3
USE CASES
USE CASES
Chess games
Data file of 2 million chess game
summaries in PGN format [Event "Masters"]
[Site "Hampstead"]
[Date "1998.03.28"]
[Round "1"]
[White "Aagaard, J. (wh)"]
[Black "Panczyk, K. (bl)"]
[Result "1/2-1/2"]
[WhiteElo "2395"]
[BlackElo "2390"]
[ECO "A32"]
1. d4 Nf6 2. c4 e6
3. Nf3 c5 4. Nc3 cxd4
5. Nxd4 Bb4 6. Nb5 a6
7. Nd6+ Ke7 8. Nxc8+ Qxc8
9. Qb3 Nc6 ...
Chess games
Data file of 2 million chess game
summaries in PGN format [Event "Masters"]
[Site "Hampstead"]
[Date "1998.03.28"]
[Round "1"]
[White "Aagaard, J. (wh)"]
[Black "Panczyk, K. (bl)"]
[Result "1/2-1/2"]
[WhiteElo "2395"]
[BlackElo "2390"]
[ECO "A32"]
1. d4 Nf6 2. c4 e6
3. Nf3 c5 4. Nc3 cxd4
5. Nxd4 Bb4 6. Nb5 a6
7. Nd6+ Ke7 8. Nxc8+ Qxc8
9. Qb3 Nc6 ...
Goal: measure first-move
advantage (more wins for
white)
Count games according to
each possible result:
1-0
0-1
½-½
(White wins)
(Black wins)
(draw)
Chess games
Data file of 2 million chess game
summaries in PGN format [Event "Masters"]
[Site "Hampstead"]
[Date "1998.03.28"]
[Round "1"]
[White "Aagaard, J. (wh)"]
[Black "Panczyk, K. (bl)"]
[Result "1/2-1/2"]
[WhiteElo "2395"]
[BlackElo "2390"]
[ECO "A32"]
1. d4 Nf6 2. c4 e6
3. Nf3 c5 4. Nc3 cxd4
5. Nxd4 Bb4 6. Nb5 a6
7. Nd6+ Ke7 8. Nxc8+ Qxc8
9. Qb3 Nc6 ...
Goal: measure first-move
advantage (more wins for
white)
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
read the file
line by line
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
retain only those
containing the result
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
slice according
to line content
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
turn each line
into 1
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
sum
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
line count
for each score
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
keep only
last event
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
print to
console
Chess games
f
f
?
1
Σ
0
+
[Result
1
A possible BeepBeep pipeline:
Output:
{
[Result "*"]=221.0,
[Result "1-0"]=852305.0,
[Result "1/2-1/2"]=690934.0,
[Result "0-1"]=653728.0
}
A program running on a Hadoop cluster processes
the 1.7 GB file in 26 minutes.*
The right tool... (cont'd)
h�ps://tomhayden3.com/2013/12/27/chess-mr-job
*
A program running on a Hadoop cluster processes
the 1.7 GB file in 26 minutes.*
The right tool... (cont'd)
h�ps://tomhayden3.com/2013/12/27/chess-mr-job
*
The BeepBeep pipeline on a desktop computer
takes...
A program running on a Hadoop cluster processes
the 1.7 GB file in 26 minutes.*
The right tool... (cont'd)
h�ps://tomhayden3.com/2013/12/27/chess-mr-job
*
The BeepBeep pipeline on a desktop computer
takes... 35 seconds.
A program running on a Hadoop cluster processes
the 1.7 GB file in 26 minutes.*
The right tool... (cont'd)
h�ps://tomhayden3.com/2013/12/27/chess-mr-job
*
The BeepBeep pipeline on a desktop computer
takes... 35 seconds.
A program running on a Hadoop cluster processes
the 1.7 GB file in 26 minutes.*
The right tool... (cont'd)
h�ps://tomhayden3.com/2013/12/27/chess-mr-job
*
The BeepBeep pipeline on a desktop computer
takes... 35 seconds.
A program running on a Hadoop cluster processes
the 1.7 GB file in 26 minutes.*
The right tool... (cont'd)
h�ps://tomhayden3.com/2013/12/27/chess-mr-job
*
The BeepBeep pipeline on a desktop computer
takes... 35 seconds.
Robots
Industrial robot moving on a shop floor, producing
an event stream of its current state
x y θ x y θ
, x y θ
, ...
θ
(x,y)
Robots
Industrial robot moving on a shop floor, producing
an event stream of its current state
x y θ x y θ
, x y θ
, ...
Goal: detect skidding
situa�ons
"large" difference between
orienta�on and mo�on
Robots
A possible pipeline:
1
f
−
f
x
Robots
A possible pipeline:
1
f
−
f
x
0 0 30° ½ ¼ 32°
Robots
A possible pipeline:
1
f
−
f
x
0 0 30° ½ ¼ 32°
½
0
Robots
A possible pipeline:
1
f
−
f
x
0 0 30° ½ ¼ 32°
½
0
½
0
Robots
A possible pipeline:
1
f
−
f
x
0 0 30° ½ ¼ 32°
½
0
½
0
½
Robots
A possible pipeline:
1
f
−
f
x
0 0 30° ½ ¼ 32°
½
0
½
0
½
½
Robots
A possible pipeline:
1
f
−
f
x
0 0 30° ½ ¼ 32°
½
0
½
0
½
½
the x-distance traveled between
two successive events
1
f
−
f
x
1
f
−
f
y
f
atan2
A possible pipeline:
Robots
1
f
−
f
x
1
f
−
f
y
f
atan2
A possible pipeline:
Robots
Δx
1
f
−
f
x
1
f
−
f
y
f
atan2
A possible pipeline:
Robots
Δx
Δy
1
f
−
f
x
1
f
−
f
y
f
atan2
A possible pipeline:
Robots
Δx
Δy
arctan( )
Δx
Δy
-
Δy
Δx
θ'
Robots
A possible pipeline:
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
Robots
A possible pipeline:
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
Robots
A possible pipeline:
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
Δθ = |θ−θ'|
f
≥
1 k
Robots
A possible pipeline:
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
Δθ = |θ−θ'|
f
≥
1 k
if Δθ ≥ k
outputs ⊤
Robots
A possible pipeline:
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
Δθ = |θ−θ'|
Robots
An isolated skidding
event is considered
a false alarm
Robots
An isolated skidding
event is considered
a false alarm
Report only if skidding
lasts for at least n
successive events
×1 ×2 ×3
Robots
A possible pipeline (final version):
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
f
≥
1 k
n
{
Σ
∧
⊤
Robots
A possible pipeline (final version):
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
f
≥
1 k
n �mes in a row
outputs if Δθ ≥ k
⊤
n
{
Σ
∧
⊤
Robots
A possible pipeline (final version):
1
f
−
f
x
1
f
−
f
y
f
atan2
f
θ
f
−
| |
f
≥
1 k
Conclusion
Event streams can be found in a variety of
situa�ons
Processing them in real �me does not (always)
require a complex/distributed setup
The BeepBeep stream processing engine can
perform a wide range of calcula�ons on streams
WARP ZONE
WARP ZONE
To be continued...
There are many more things to explore!
Pale�e
Set of processors and func�ons,
centered around a par�cular use case
There are dozens of pale�es that
extend the set of core processors for
various scenarios
→
→
?
?
T
/a/b
//status/text()
=? Walker
*
/a/b
//status/text()
=? Blocker
*
*
Guards on transi�ons
are arbitrary func�ons
on events
States output values
of any type (Moore machine)
Finite-state (i.e. Moore) machines
Linear Temporal Logic
X
G F
U
1
<
Σ f
⊥
<
Σ f
⊥
F
G
=
= =
= Σ f
?
♣

More Related Content

PDF
Event Stream Processing with Multiple Threads
PPTX
Flink. Pure Streaming
PDF
Mining event streams with BeepBeep 3
PDF
Streaming Dataflow with Apache Flink
PDF
Arduino programming of ML-style in ATS
PDF
Greyhound - Powerful Functional Kafka Library - Devtalks reimagined
PDF
Correctness attraction __kth_2017
PDF
Buffer overflow null
Event Stream Processing with Multiple Threads
Flink. Pure Streaming
Mining event streams with BeepBeep 3
Streaming Dataflow with Apache Flink
Arduino programming of ML-style in ATS
Greyhound - Powerful Functional Kafka Library - Devtalks reimagined
Correctness attraction __kth_2017
Buffer overflow null

Similar to Event Stream Processing with BeepBeep 3 (20)

PDF
Tail Call Elimination in Open Smalltalk
PDF
A Stream-Based Approach to Intrusion Detection
PDF
Greyhound - Powerful Pure Functional Kafka Library
ODP
Exact Real Arithmetic for Tcl
PDF
GNU Parallel
PPTX
Split Miner: Discovering Accurate and Simple Business Process Models from Eve...
PDF
Orchestrated Chaos: Applying Failure Testing Research at Scale.
PDF
Incremental Graph Queries for Cypher
PDF
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
PPT
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
PPT
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
PDF
Talk About Performance
PDF
Need this Urgent FInal answer is enough 3 What would b.pdf
PDF
Functional Reactive Programming / Compositional Event Systems
PDF
Compliance monitoring of multi-perspective declarative process models
PDF
UM2019 Extended BPF: A New Type of Software
PDF
Concurrecny inf sharp
PDF
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
PDF
Self Managed and Automatically Reconfigurable Stream Processing - Vasiliki Ka...
PDF
Self-managed and automatically reconfigurable stream processing
Tail Call Elimination in Open Smalltalk
A Stream-Based Approach to Intrusion Detection
Greyhound - Powerful Pure Functional Kafka Library
Exact Real Arithmetic for Tcl
GNU Parallel
Split Miner: Discovering Accurate and Simple Business Process Models from Eve...
Orchestrated Chaos: Applying Failure Testing Research at Scale.
Incremental Graph Queries for Cypher
Exactly Once Semantics Revisited (Jason Gustafson, Confluent) Kafka Summit NY...
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Talk About Performance
Need this Urgent FInal answer is enough 3 What would b.pdf
Functional Reactive Programming / Compositional Event Systems
Compliance monitoring of multi-perspective declarative process models
UM2019 Extended BPF: A New Type of Software
Concurrecny inf sharp
Continuous Delivery and Zero Downtime: What your architecture needs to succeed
Self Managed and Automatically Reconfigurable Stream Processing - Vasiliki Ka...
Self-managed and automatically reconfigurable stream processing
Ad

More from Sylvain Hallé (20)

PDF
A Tree-Based Definition of Business Process Conformance (Talk @ EDOC 2024)
PDF
Monitoring Business Process Compliance Across Multiple Executions with Stream...
PDF
Smart Contracts-Enabled Simulation for Hyperconnected Logistics
PDF
Test Suite Generation for Boolean Conditions with Equivalence Class Partitioning
PDF
Synthia: a Generic and Flexible Data Structure Generator (Long Version)
PDF
Test Sequence Generation with Cayley Graphs (Talk @ A-MOST 2021)
PDF
Efficient Offline Monitoring of LTL with Bit Vectors (Talk at SAC 2021)
PDF
A Generic Explainability Framework for Function Circuits
PDF
Detecting Responsive Web Design Bugs with Declarative Specifications
PDF
Streamlining the Inclusion of Computer Experiments in Research Papers
PDF
Writing Domain-Specific Languages for BeepBeep
PDF
Real-Time Data Mining for Event Streams
PDF
Technologies intelligentes d'aide au développement d'applications web (WAQ 2018)
PDF
LabPal: Repeatable Computer Experiments Made Easy (ACM Workshop Talk)
PDF
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
PDF
A Few Things We Heard About RV Tools (Position Paper)
PDF
Solving Equations on Words with Morphisms and Antimorphisms
PDF
Runtime monitoring de propriétés temporelles par (streaming) XML
PDF
La quantification du premier ordre en logique temporelle
PDF
When RV Meets CEP (RV 2016 Tutorial)
A Tree-Based Definition of Business Process Conformance (Talk @ EDOC 2024)
Monitoring Business Process Compliance Across Multiple Executions with Stream...
Smart Contracts-Enabled Simulation for Hyperconnected Logistics
Test Suite Generation for Boolean Conditions with Equivalence Class Partitioning
Synthia: a Generic and Flexible Data Structure Generator (Long Version)
Test Sequence Generation with Cayley Graphs (Talk @ A-MOST 2021)
Efficient Offline Monitoring of LTL with Bit Vectors (Talk at SAC 2021)
A Generic Explainability Framework for Function Circuits
Detecting Responsive Web Design Bugs with Declarative Specifications
Streamlining the Inclusion of Computer Experiments in Research Papers
Writing Domain-Specific Languages for BeepBeep
Real-Time Data Mining for Event Streams
Technologies intelligentes d'aide au développement d'applications web (WAQ 2018)
LabPal: Repeatable Computer Experiments Made Easy (ACM Workshop Talk)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A Few Things We Heard About RV Tools (Position Paper)
Solving Equations on Words with Morphisms and Antimorphisms
Runtime monitoring de propriétés temporelles par (streaming) XML
La quantification du premier ordre en logique temporelle
When RV Meets CEP (RV 2016 Tutorial)
Ad

Recently uploaded (20)

PPTX
sap open course for s4hana steps from ECC to s4
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Electronic commerce courselecture one. Pdf
PPTX
Cloud computing and distributed systems.
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Big Data Technologies - Introduction.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
sap open course for s4hana steps from ECC to s4
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Empathic Computing: Creating Shared Understanding
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
MIND Revenue Release Quarter 2 2025 Press Release
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Electronic commerce courselecture one. Pdf
Cloud computing and distributed systems.
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
Big Data Technologies - Introduction.pptx
Spectral efficient network and resource selection model in 5G networks
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx

Event Stream Processing with BeepBeep 3