I count events within a timed window. If more than 5 events arrive at that window, then I want to discard them all. Otherwise, the events are released after the waiting time.
My code goes something like this:
// Create a timed window of 10 seconds
create window MyWindow.win:time(10 sec) as MyEventType;
// Add to the timed window
insert into MyWindow select * from MyEventType;
//Delete from window if upper limit was reached
On MyEventType as newEvent
select and delete * from MyWindow as oldEvent
having COUNT(*) >= 5;
Additionally, a listener receives all events that leave the timed window:
select rstream * from MyWindow;
The problem with the example above is that both deleted and released events are forwarded to the listener (via rstream
).
Question: how to differentiate deleted events from released ones?