I have a steam of ThingEvent
.
create schema ThingEvent {
thingID int,
isLast boolean
}
I want to process things with the same thingID
s together so I created a context.
create context ThingContext
partition by thingID from ThingEvent
However, when I get a thing with isLast
set to true
, that means we're never going to see a ThingEvent
with the same thingID
again. But the context will hang around forever causing a resource leak.
I found that an overlapping context can be terminated.
create context ThingContext
initiated by distinct(thingID) ThingEvent(isLast <> true) as startEvent
terminated by ThingEvent(thingID = startEvent.thingID, isLast = true);
But when I use it, I have to manually filter the events.
context ThingContext
select *
from ThingEvent(thingID=context.startEvent.thingID)
output when terminated;
When I start using patterns, this becomes way too verbose. Is there a way to get the best of both worlds?
I don't think there is a termination clause for keyed contexts.
There is a programmatic way of termination any context partition, link to documentation.
Instead of repeating expressions there is a predefined expression alias "expression alias {}".
This functionality was added in the 7.0.0 release http://www.espertech.com/esper/esper-changehistory/