gpt4 book ai didi

postgresql - Siddhi 中触发器的运行时间

转载 作者:行者123 更新时间:2023-11-29 13:52:57 26 4
gpt4 key购买 nike

我想从 siddhi 读取 postgres 表,我正在使用触发器:

@From(eventtable='rdbms', jdbc.url='jdbc:postgresql://localhost:5432/pruebabg', username='postgres', password='Easysoft16', driver.name='org.postgresql.Driver', table.name='Trazablack')
define table Trazablack (sensorValue double);

define trigger FiveMinTriggerStream at every 10 min;

from FiveMinTriggerStream join Trazablack as t
select t.sensorValue as sensorValue
insert into StreamBlack;

但是,我有一个问题,查询每 10 分钟运行一次,我需要在新事件到达时运行。

这可能吗?

from sensorStream#window.length(2) 
JOIN StreamBlack#window.length(1)
on sensorStream.sensorValue==StreamBlack.sensorValue
select sensorStream.meta_timestamp, sensorStream.meta_sensorName, sensorStream.correlation_longitude,
sensorStream.correlation_latitude, sensorStream.sensorValue as valor1, StreamBlack.sensorValue as valor2
insert INTO StreamPaso;


from sensorStream#window.length(2)
LEFT OUTER JOIN StreamBlack#window.length(1)
on sensorStream.sensorValue==StreamBlack.sensorValue
select sensorStream.meta_timestamp, sensorStream.meta_sensorName, sensorStream.correlation_longitude,
sensorStream.correlation_latitude, sensorStream.sensorValue as valor1, StreamBlack.sensorValue as valor2
insert INTO StreamPaso;

最佳答案

在这种情况下,您可以简单地使用输入流进行连接,而不是使用窗口触发流。我们可以使用 0 长度的窗口,因为我们不需要在窗口中存储任何内容,并且我们需要在事件通过流到达时触发查询。我们还可以使用“当前事件”(即传入事件)子句来确保不考虑窗口的“过期事件”(即窗口保留和发出的事件)(有关更多信息,请参阅 Siddhi QL documentation on windows)。

例如(假设 sensorStream 是输入流):

from sensorStream#window.length(0) join Trazablack as t
select t.sensorValue as sensorValue
insert current events into StreamBlack;

关于postgresql - Siddhi 中触发器的运行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37471839/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com