Select 个滑动最大值的事件 window

Select events with a maximum in a sliding window

我有这个流:

define stream locationStream (cell string, device string, power long);

我想 select 在此流中,滑动 windows 10 秒,对于每个设备, 'cell' 属性的值 'power'是最大的。

我应该使用什么查询来获得 Siddhi 的结果?像

from locationStream#window.time(10 seconds)
select max(power), device, <cell where power = max(power)>
group by device
insert all events into cellStream

您可以使用 Siddhi maxByTimeWindow offered through extrema 扩展。用法记录在共享资源中。您必须将其与分区一起使用才能获得每个设备的最大值。建议的查询应如下所示。

partition with ( device of locationStream )
begin
  from locationStream#extrema:maxByTime(power, 10 sec)
  select power, device, cell
  insert events into cellStream
end;