如何使用siddhi实现执行计划



首先让我描述一下我的需求:

data.csv:第一列是id,第二列是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

这是我的InputStreamOutPutStream:

id int,value int

data.csv将使用事件流模拟器插入输入流

如果有五个连续的值>=85,我会将第一个id值记录到OutPutStream中。例如,我将记录id=4,值=86,但id=14到id=17,我将忽略它

那么,如何在执行计划中编写siddhi脚本来实现它呢?

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

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

对于恰好五个连续值>=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;

对于五个以上的连续值>=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;
from every a1=InputStream[value>=85], a1=InputStream[value>=85]<4> 
select a1.id, a1.value
insert into OutPutStream;

应该有效!

最新更新