Esper终止分区上下文

时间:2017-11-01 21:46:29

标签: esper complex-event-processing

我有ThingEvent的热情。

create schema ThingEvent {
  thingID int,
  isLast  boolean
}

我想要处理具有相同thingID s的内容,因此我创建了一个上下文。

create context ThingContext
  partition by thingID from ThingEvent

但是,当我将isLast设置为true时,这意味着我们永远不会再看到ThingEvent thingID。但是上下文将永远存在,导致资源泄漏。

我发现可以终止overlapping context

create context ThingContext
  initiated by distinct(thingID) ThingEvent(isLast <> true) as startEvent
  terminated by ThingEvent(thingID = startEvent.thingID, isLast = true);

但是当我使用它时,我必须手动过滤事件。

context ThingContext
  select *
  from ThingEvent(thingID=context.startEvent.thingID)
  output when terminated;

当我开始使用模式时,这变得过于冗长。有没有办法让两全其美?

1 个答案:

答案 0 :(得分:1)

我不认为键控上下文有终止条款。

有一种以编程方式终止任何上下文分区link to documentation

而不是重复表达式,有一个预定义的表达式别名&#34;表达别名{}&#34;。

编辑:

此功能已添加到7.0.0发行版http://www.espertech.com/esper/esper-changehistory/