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



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

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

~~~~

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

最佳答案

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

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;

09-25 20:14