willxiang
willxiang

Reputation: 291

How to implement execution plans using siddhi?

First of all let me description my requirement:

data.csv: column one is id,column two is vlaue.

1,0
2,0
3,0
4,86
5,87
6,88
7,89
8,86
9,0
10,0
11,0
12,0
13,0
14,86
15,87
16,88
17,89
18,0
19,0
20,0

here is my InputStream and my OutPutStream:

id int,value int

data.csv will insert into InputStream by using Event Stream Simulator.

If there are five consecutive value>=85, I would record the first id,value into OutPutStream. For example,I will record id=4,value=86 ,but id=14 to id=17 i will ignore it.

So how can i write siddhi script in execution plans to implement it?

==========================================================================

data2.csv:

1,0
2,0
3,0
4,86
5,87
6,88
7,89
8,86
9,87
10,88
11,89
12,90
13,91
14,86
15,87
16,88
17,89
18,90
19,90
20,90
21,0
22,0,
23,87
24,85
25,86
26,0
27,17
...
200,91
201,0

Upvotes: 0

Views: 275

Answers (2)

Grainier
Grainier

Reputation: 1654

For exactly five consecutive values >= 85

from every a1=InputStream[value>=85], a2=InputStream[value>=85]+, a3=InputStream[value<85]
select a1.id, a1.value
having (not (a2[3] is null)) and (a2[4] is null)
insert into OutPutStream;

For more than five consecutive values >= 85

from every a1=InputStream[value>=85], a2=InputStream[value>=85]+, a3=InputStream[value<85]
select a1.id, a1.value
having (not (a2[3] is null))
insert into OutPutStream;

Upvotes: 1

suho
suho

Reputation: 912

from every a1=InputStream[value>=85], a1=InputStream[value>=85]<4> 
select a1.id, a1.value
insert into OutPutStream;

Should work!

Upvotes: 0

Related Questions