Amit Maniar
Amit Maniar

Reputation: 1196

esper fixed window based on event starting time

I am using Esper for Aggregating my Sensor Data. Data may arrive in any interval i.e. 1 seconds to 120 seconds. Each data point contains TimeStamp and Value.

I want Min TimeStamp, Max TimeStamp, Average value and Count of data points in 30 min window. Start point and end point of 30 min window is fixed i.e. 01:00 am to 01:30 am, 01:30 am to 02:00 am, etc

How can I achieve this using Esper ?

Upvotes: 0

Views: 759

Answers (3)

barkha mehra
barkha mehra

Reputation: 34

Either

win:ext_timed_batch(TimeStamp.withTime(TimeStamp.getHourOfDay(), cast(TimeStamp.getMinuteOfHour()/30, int) * 30, 0, 0).toMillisec(),30 min)

Or

win:ext_timed_batch(TimeStamp.toMillisec() -(TimeStamp.toMillisec()%1800000), 30 min) where 1800000 is the number of milliseconds for 30 mins(30*60*1000)

Upvotes: 1

Bhavin Shah
Bhavin Shah

Reputation: 120

Externally-timed batch window (win:ext_timed_batch) should work for you. But its available from Esper 4.8.0 I think http://esper.codehaus.org/esper-4.8.0/doc/reference/en-US/html_single/index.html#view-win-ext-time-batch

Upvotes: 1

user3613754
user3613754

Reputation: 816

So for example see "4.2.7.3. Crontab Context Condition":

create context Every30Min start (*/30, *, *, *, *) end after 30 min; context Every30Min select count(*) from MyEvent output snapshot when terminated;

Upvotes: 0

Related Questions