0

Is it possible in Esper to manage timestamp from an input. The file I use looks like this:

143 Sat Sep 12 14:43:05 CEST 2009
149 Sat Sep 12 14:43:06 CEST 2009
149 Sat Sep 12 14:43:09 CEST 2009
143 Sat Sep 12 14:43:10 CEST 2009
149 Sat Sep 12 14:43:12 CEST 2009
143 Sat Sep 12 14:43:15 CEST 2009
149 Sat Sep 12 14:43:15 CEST 2009
149 Sat Sep 12 14:43:18 CEST 2009
143 Sat Sep 12 14:43:20 CEST 2009
149 Sat Sep 12 14:43:21 CEST 2009

How do configure Esper so it is possible to use the

select * from Timer.win:time_batch(5 sec)

such that I get results like this:

143 Sat Sep 12 14:43:05 CEST 2009
149 Sat Sep 12 14:43:06 CEST 2009
149 Sat Sep 12 14:43:09 CEST 2009
143 Sat Sep 12 14:43:10 CEST 2009

EDIT:

config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);

runtime.sendEvent(new CurrentTimeEvent(0));
engine.getEPAdministrator().createEPL("create context NineToFive start (0, 9, *, *, *) end (0, 17, *, *, *)");

Then I parse my dataset and send events like the answer below said:

long eventTime = userByDate.get(i).getSdf().getTime();

runtime.sendEvent(new CurrentTimeSpanEvent( eventTime ));
runtime.sendEvent(new Event());
sweep
  • 75
  • 9

1 Answers1

0

Steps are, get an engine instance from EPServiceProviderManager that uses external timer:

Configuration config = new Configuration();
config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);

After you have an engine instance, call this. This sets the start time to zero.

epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));

Then create your EPL statement.

Then, for each line, parse the date, parse the event data, advance time, and send the event like this:

long eventTime = parseDate(...);
SomeEvent someEvent = parseEvent(...);
epService.getEPRuntime().sendEvent(new CurrentTimeSpanEvent(eventTime));
epService.getEPRuntime().sendEvent(someEvent);
goodie
  • 364
  • 1
  • 2
  • 4
  • I noticed when using contexts, it still answers to the internal timer instead of the external one. Even when I turned it off. Maybe something with my setup. – sweep Feb 02 '17 at 21:33
  • Even when setting the time before i declare my context. It gives an output, but not the correct one. – sweep Feb 02 '17 at 22:04
  • Suggest to post the code. If you look at Esper code you can see that external and internal/system time is really the same internally. Therefore contexts don't really make a difference. – goodie Feb 03 '17 at 15:05
  • nvm got it working. Added code for working example. However since time interval in the timestamps are not the same i guess Esper does an estimate when specifying time.Thanks you for the help though. – sweep Feb 06 '17 at 13:49