Esper中的强制输出

Esper中的强制输出,esper,Esper,我有一个非实时Esper配置,其中我提供了一个从文件读取的流。我试图创建一个表达式,它计算整个流的统计信息,并在最后输出一个值。例如,Esper有强制视图每X秒输出一次的语义,但有没有语义要求视图或引擎在知道没有更多事件可供馈送时“刷新”输出。结果表明,至少有一种方法是使用带有变量触发器的output子句 表达方式是: select count(*) as totalCount from events output last when OutputSummary = true select e

我有一个非实时Esper配置,其中我提供了一个从文件读取的流。我试图创建一个表达式,它计算整个流的统计信息,并在最后输出一个值。例如,Esper有强制视图每X秒输出一次的语义,但有没有语义要求视图或引擎在知道没有更多事件可供馈送时“刷新”输出。

结果表明,至少有一种方法是使用带有变量触发器的output子句

表达方式是:

select count(*) as totalCount from events output last when OutputSummary = true
select emplyee_id from employees output snapshot every 60 sec
select emplyee_id from employees output snapshot every 10000 events
OutputSummary变量的初始化如下:

epConfiguration.addVariable("OutputSummary", Boolean.class, "false");
准备刷新时,将变量设置为true,如下所示:

epRuntime.setVariableValue("OutputSummary", true);
long currentTime = epService.getEPRuntime().getCurrentTime();
epRuntime.sendEvent(new CurrentTimeEvent(currentTime));

有必要发送另一个时间事件以强制表达式求值。

当输出要求每60秒计算一次时,表达式将为:

select count(*) as totalCount from events output last when OutputSummary = true
select emplyee_id from employees output snapshot every 60 sec
select emplyee_id from employees output snapshot every 10000 events
当输出要求每10000个事件时,表达式为:

select count(*) as totalCount from events output last when OutputSummary = true
select emplyee_id from employees output snapshot every 60 sec
select emplyee_id from employees output snapshot every 10000 events