我如何使用Siddhi从事件的连续值中挑选出价值 [英] How can i pick out value from consecutive value of event by using siddhi

查看:242
本文介绍了我如何使用Siddhi从事件的连续值中挑选出价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如数据:

1,1470732420000,0
2,1470732421000,0
3,1470732422000,0
4,1470732423000,86
5,1470732424000,87
6,1470732425000,88
7,1470732426000,84
8,1470732427000,0
9,1470732428000,0
10,1470732429000,0
11,1470732430000,89
12,1470732431000,89
13,1470732432000,87
14,1470732433000,89
15,1470732434000,85
16,1470732435000,89
17,1470732436000,89
18,1470732437000,87
19,1470732438000,86
20,1470732439000,88
21,1470732440000,0
22,1470732441000,0
23,1470732442000,0
24,1470732443000,87
25,1470732444000,85
26,1470732445000,86
27,1470732446000,0
28,1470732447000,0
29,1470732448000,0
30,1470732449000,0

第1列是 id ,第2列是时间戳,第3列是 value ,时间戳之间的间隔为1秒.

column one is id,column two is timestamp,column three is value,1 sec interval between the timestamp.

我要监视事件的值,如果我发现值> = 85(例如,id = 4),则我将开始计数,如果接下来的两个连续值> = 85(例如,id = 5/id = 6) ,然后我将event的第三个值放入OutputStream.(例如id = 6,value = 88,timestamp = 1470732425000)

i want monitoring the value of event,if i found out value>=85(e.g. id=4), i will starting counting,if the next two consecutive value>=85(e.g. id=5/id=6),then i will put the third value of event to OutputStream.(e.g. id=6,value=88,timestamp=1470732425000)

同时我清除计数和等待值小于85(例如id = 7,value = 84),然后当我发现值> = 85(例如id = 11,value = 89)我将开始计数,如果接下来的两个连续值> = 85(例如id = 12/id = 13),那么我会将事件的第三个值放入OutputStream.(例如id = 13,value = 87,timestamp = 1470732432000)...

at the same time i clear the counting and wait value lower than 85(e.g. id=7,value=84), then i will monitoring again,when i found out value>=85(e.g. id=11,value=89) i will starting counting,if the next two consecutive value>=85(e.g. id=12/id=13),then i will put the third value of event to OutputStream.(e.g. id=13,value=87,timestamp=1470732432000)...

这就是我想做的,在我发布此问题之前,我已经在

all this is i wanna do,before i post this ask, i've got an answer in this post,i've tried this code:

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

它可以工作,但是我发现它将在值< = 85之后将值插入到OutputStream中,如果我得到三个连续的值> = 85,我想要的是立即将其插入到值中.不想一直等待下一个值> = 85) 实际上,我只想在连续三秒value(> = 85)中记录第三秒的值. 我正在使用wso2das-3.1.0-SNAPSHOT.

and it works,but i found out it will insert the value into OutputStream after the value<=85,and what i want is if i got three consecutive value>=85 then i insert into the value immediately.(i don't want to wait if the next value>=85 all the times) in fact, i just wanna record value of third seconds in three consecutive seconds value(>=85) . i'm using wso2das-3.1.0-SNAPSHOT.

推荐答案

尽管DAS(Siddhi)支持序列/模式处理,但您可能需要编写自定义扩展名.我已经编写了一个示例窗口处理器扩展,以满足您的需求(<das_home>/repository/components/lib/目录中的raw = true"rel =" nofollow> siddhi-extension-condition-window-1.0.jar 并重新启动服务器.请参阅

Though DAS (Siddhi) supports sequence/pattern processing, for your requirement you might need to write a custom extension. I have written a sample window processor extension to cater your requirement (source code). Download and place siddhi-extension-condition-window-1.0.jar in <das_home>/repository/components/lib/ directory and restart the server. Refer to the test case to get an idea of the usage of the extension.

这篇关于我如何使用Siddhi从事件的连续值中挑选出价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆