gpt4 book ai didi

Esper EPL 查询时间(t)和时间(t-1)

转载 作者:行者123 更新时间:2023-12-02 07:50:40 26 4
gpt4 key购买 nike

我正在尝试实现一个 EPL 查询,该查询可以获取 Time(t) 和 Time(t-1) 的平均值。

For example:

a) in the first 5 seconds (seconds 0-5) there are 2 events with an avg of 12

b) in the next 5 seconds (seconds 5-10) there are 3 events with an avg of 23 , and in the EPL query that catches this information, I am able to also see the avg of 12 from the previous time window of the first 5 seconds

我的想法是以最终 epl 查询具有 Time(t) 和 Time(t-1) 的快照的方式交错对象/查询,如虚拟创建的对象 ScoreInfoBeforeAfter 所示。但是它不起作用。

任何想法将不胜感激。谢谢。

~~~~

// The object being published to the Esper stream:
class ScoreEvent { int score; ... }

最佳答案

看起来关键字prior 是解决方案。

http://esper.codehaus.org/esper-2.1.0/doc/reference/en/html/functionreference.html

参见:第 7.1.9 节

根据我在原帖中描述的例子,这是我找到的相应解决方案。它似乎工作正常。

INSERT INTO ScoreInfo
SELECT
'ScoreInfo' as a_Label,
average AS curAvg,
prior(1, average) AS prevAvg
FROM
ScoreEvent.win:time_batch(5 sec).stat:uni(score);


SELECT
*
FROM
ScoreInfo.win:length(1);

..
然后它很好,因为你可以做这样的事情:

SELECT
'GT curAvg > prevAvg' as a_Label,
curAvg,
prevAvg
FROM
ScoreInfo.win:length(1)
WHERE
curAvg > prevAvg;


SELECT
'LTE curAvg <= prevAvg' as a_Label,
curAvg,
prevAvg
FROM
ScoreInfo.win:length(1)
WHERE
curAvg <= prevAvg;

关于Esper EPL 查询时间(t)和时间(t-1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4027311/

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