How to implement execution plans using siddhi?

寵の児 提交于 2020-01-06 19:51:21

问题


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

回答1:


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;



回答2:


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

Should work!



来源:https://stackoverflow.com/questions/38893507/how-to-implement-execution-plans-using-siddhi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!