esper聚合计数查询输出意外

时间:2014-06-30 06:02:39

标签: streaming complex-event-processing esper

我要将城市名称,公司名称发送给esper。

这些查询将在5秒内计算名称公司对的出现次数:

create context FiveSecondsContext start @now end after 5 seconds; 

context FiveSecondsContext 
        insert into AggregatedEvent1 
                        select count(*) as count, company, name from eBay group by name, company output snapshot when terminated; 

下面的查询应该为FiveSecondsContext末尾的每个城市提供最大数量。我在SQL中的知识似乎是正确的,但它并没有给我max,它返回AggregatedEvent1中的所有行。

   insert into AggrEvent2 
                select max(count) as value, company, name from AggregatedEvent1 group by name; 

由于上面出错了,我的查询在下面

select count(*) as cnt, company from AggrEvent2 group by company; 

试图计算公司(例如:" yahoo")具有最大计数的城市名称也出错了,并给出了初始查询输入中所有公司名称出现次数。

  1. 问题出在groupby子句或
  2. 我需要确定查询的运行顺序。因为我只为AggregatedEvent1定义了上下文。

1 个答案:

答案 0 :(得分:0)

这取决于select中的内容和组中的内容,与关系数据库中的内容相同。你可以在这里阅读:http://esper.codehaus.org/esper-5.0.0/doc/reference/en-US/html_single/index.html#processingmodel_aggregation_output 删除"公司"从选择或添加公司到组似乎是这样做的。