如何 select n 没有。事件并比较所有事件?
How to select n no. of events and compare all events?
通过在传入事件之间建立关联,我们可以根据指定的时间范围对过去的数据进行一些计算。
As mentioned here.
我正在做类似的事情,以使用 within
关键字接收基于某个指定时间范围的事件。
@info(name='dg-start-check-query')
from every (e1=InputStream) -> e2=InputStream[e1.meter_id=='s1' and e2.meter_id=='s1' and convert(e2.current_avg, 'double')-convert(e1.current_avg, 'double')==convert(e2.current_avg, 'double') and convert(e1.current_avg, 'double')+convert(e2.current_avg, 'double')!=0 and convert(e1.current_avg, 'double')==0]
within 1 min
select time:dateFormat(e2.device_time, 'HH:mm:ss.SSS yyyy-MM-dd') as date_time
insert into OutputStreamStarted;
如何让此代码仅接收过去的 2 或 3 个事件并对其进行计算,就像使用 window
收集事件一样?
此代码将在给定时间范围内接收所有事件,并在多个事件满足其条件时多次执行。
您可以将 defined length window to achieve this requirement. For each incoming event perform unidirectional join 与 window 一起使用,然后再放入 window。您的条件可以进入加入条件。下面给出了示例查询。你需要在你的逻辑条件下工作,因为那些需要改进。
define stream InputStream (meter_id string, current_avg string, device_time int);
define window eventWindow (meter_id string, current_avg string, device_time int) length(2);
@info(name = 'query1') from InputStream[meter_id=='s1']#window.length(1) as e1 unidirectional join eventWindow as e2
on (convert(e2.current_avg, 'double')-convert(e1.current_avg, 'double')==convert(e2.current_avg, 'double'))
select e1.device_time insert into OutputStreamStarted ;
@info(name = 'query2') from InputStream[meter_id=='s1']
select meter_id, current_avg, device_time
insert into eventWindow ;
通过在传入事件之间建立关联,我们可以根据指定的时间范围对过去的数据进行一些计算。 As mentioned here.
我正在做类似的事情,以使用 within
关键字接收基于某个指定时间范围的事件。
@info(name='dg-start-check-query')
from every (e1=InputStream) -> e2=InputStream[e1.meter_id=='s1' and e2.meter_id=='s1' and convert(e2.current_avg, 'double')-convert(e1.current_avg, 'double')==convert(e2.current_avg, 'double') and convert(e1.current_avg, 'double')+convert(e2.current_avg, 'double')!=0 and convert(e1.current_avg, 'double')==0]
within 1 min
select time:dateFormat(e2.device_time, 'HH:mm:ss.SSS yyyy-MM-dd') as date_time
insert into OutputStreamStarted;
如何让此代码仅接收过去的 2 或 3 个事件并对其进行计算,就像使用 window
收集事件一样?
此代码将在给定时间范围内接收所有事件,并在多个事件满足其条件时多次执行。
您可以将 defined length window to achieve this requirement. For each incoming event perform unidirectional join 与 window 一起使用,然后再放入 window。您的条件可以进入加入条件。下面给出了示例查询。你需要在你的逻辑条件下工作,因为那些需要改进。
define stream InputStream (meter_id string, current_avg string, device_time int);
define window eventWindow (meter_id string, current_avg string, device_time int) length(2);
@info(name = 'query1') from InputStream[meter_id=='s1']#window.length(1) as e1 unidirectional join eventWindow as e2
on (convert(e2.current_avg, 'double')-convert(e1.current_avg, 'double')==convert(e2.current_avg, 'double'))
select e1.device_time insert into OutputStreamStarted ;
@info(name = 'query2') from InputStream[meter_id=='s1']
select meter_id, current_avg, device_time
insert into eventWindow ;