我很难理解这个问题:
from heartbeats#window.time(1 hour) insert expired events into delayedStream;
from every e = heartbeats -> e2 = heartbeats[deviceId == e.deviceId]
or expired = delayedStream[deviceId == e.deviceId]
within 1 hour 10 minutes
select e.deviceId, e2.deviceId as id2, expired.deviceId as id3
insert into tmpStream;这是可行的,但我不明白这部分:
来自每一个e=心跳-> e2 = heartbeatsdeviceId == e.deviceId或过期= delayedStreamdeviceId == e.deviceId
查询的第二部分(或失效=.)检查具有给定deviceId的事件是否位于delayedStream上。第一部分的目的是什么,以及它是如何结合在一起的,这个查询发现的设备没有发送超过1小时的数据?
发布于 2019-07-19 11:23:20
我不认为上述查询将是准确的,如果您想检查传感器是否没有发送读取在过去1小时。我把窗户调整为1分钟,发送了两个事件,
[2019-07-19 16:48:23,774] heartbeats : Event{timestamp=1563535103772, data=[1], isExpired=false}
[2019-07-19 16:48:24,696] tmpStream : Event{timestamp=1563535104694, data=[1, 1, null], isExpired=false}
[2019-07-19 16:48:24,697] heartbeats : Event{timestamp=1563535104694, data=[1], isExpired=false}
[2019-07-19 16:49:23,774] tmpStream : Event{timestamp=1563535163772, data=[1, null, 1], isExpired=false}假设事件在10和10.15到达,tmpStream的输出将分别为10.15 (第一部分)和11 (由于流延迟)。第二个匹配是不正确的,因为它必须按照每个用例在11.15匹配。
但是,如果您想改进查询,可以在用例https://siddhi.io/en/v5.0/docs/query-guide/#detecting-non-occurring-events中使用Siddhi检测无发生模式特性,这将更加简单。
https://stackoverflow.com/questions/56946907
复制相似问题