在Esper中强制输出

发布于 2024-08-19 03:39:15 字数 136 浏览 3 评论 0原文

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

I have a non real time Esper configuration where I feed a stream that I read from a file. I'm trying to create an expression that computes a statistic over the entire stream and outputs one value at the very end. Esper has semantics for forcing a view to output every X seconds, for instance, but is there a semantic for asking the view or the engine to "flush" the output when you know there are no more events to feed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮邮递员 2024-08-26 03:39:15

事实证明,至少有一种方法可以做到这一点,即使用带有变量触发器的输出子句。

表达式将是:

select count(*) as totalCount from events output last when OutputSummary = true

OutputSummary 变量将像这样初始化:

epConfiguration.addVariable("OutputSummary", Boolean.class, "false");

当您准备好刷新时,将变量设置为 true,如下所示:

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

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

Turns out that at least one way to do this is to use the output clause with a variable trigger.

The expression would be:

select count(*) as totalCount from events output last when OutputSummary = true

The OutputSummary variable would be initialized like so:

epConfiguration.addVariable("OutputSummary", Boolean.class, "false");

When you're ready to flush, set the variable to true like so:

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

It's necessary to send another time event to force the expression to evaluate.

遥远的她 2024-08-26 03:39:15

当输出需要每 60 秒时,则表达式将为:

select emplyee_id from employees output snapshot every 60 sec

当输出需要每 10000 个事件时,表达式将为:

select emplyee_id from employees output snapshot every 10000 events

When output requires at every 60 sec then the expression would be:

select emplyee_id from employees output snapshot every 60 sec

and when the output requires at every 10000 events then the expression would be:

select emplyee_id from employees output snapshot every 10000 events
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文