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

Gen*_* Bo 2 esper epl

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

例如:

a)在前5秒(秒0-5)中有2个事件,平均值为12

b)在接下来的5秒(秒5-10)中有3个事件,其平均值为23,并且在EPL查询中捕获此信息,我还能够看到前一个时间窗口中的12个平均值.前5秒

我的想法是错开对象/查询,使得最终的epl查询具有Time(t)和Time(t-1)的快照,如虚拟创建的对象ScoreInfoBeforeAfter中所示.然而,它不起作用.

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

~~~~

// The object being published to the Esper stream:
class ScoreEvent { int score; ... }
Run Code Online (Sandbox Code Playgroud)

Gen*_* Bo 7

看起来关键字优先是解决方案.

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);
Run Code Online (Sandbox Code Playgroud)

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

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;
Run Code Online (Sandbox Code Playgroud)