EPL is powerful, but unfortunately this also means that when you design EPL you need to know how time passes and what event ordering is available or not. You can run Esper in an environment that doesn't pass time and that has completely disordered events.
There are many facilities that EPL offers that do not at all depend on event order or time passing. Some examples are...
- A join
select * from OrderEvent#unique(orderId) as ord, AccountEvent#unique(accountId) as act where ord.accountId = act.accountIdjoins the last order event per order id with the last account event per account id
- An aggregation
select count(*), ip_address from PortScanEvent group by ip_addresscounts the port scans per ip address
- A complex filter
create context DynamicFilterContext initiated by CriteriaEvent as criteriaand
context DynamicFilterContext select * from News(language IN (context.criteria.languageIds) AND companies.anyOf(x=> x.company.id IN (context.criteria.companyIds))allows you to dynamically filter news based on a criteria event (this sort of thing makes use of Esper filter indexes to fast-match)
Many facilities that EPL offers however do depend on time passing and do depend on event ordering. For example...
- A pattern
timer:interval(1 minute) and not SensorEventalerts when an interval of one minute passes during which Esper receives no sensor event
- A pattern
match-recognize ( pattern (A B) )matches when there is an event A that is immediately followed by an event B
When you run Esper, you need to look at your requirements and decide for each requirement whether you need to wait for late arriving events, and for how long to wait, and what to do for events that arrive later than that. You need to determine if and how you want to advance time. You need to determine whether to reorder events. Esper has a time-order window that can help with all that however you still need to define these parameters.
timer:interval(1 minute) and not SensorEvent detects the absence of the event with near-zero latency by itself. The actual latency depends on how time moves forward. For example your design may use a watermark and move its time based on allowed lateness. The 1 minute interval can span any amount of actual natural time, and so can the latency of detection when using watermarks.
timer:interval(1 minute) and not SensorEvent outputs a result after 1 minute without a sensor event. Assume that at a later time we do discover that a sensor event has come in. This would mean the output needs to be retracted. Retraction is not something that Esper handles currently.