I am doing a length-window based program in Esper.But when the window is full,the previous event should be become an old event.When i am trying to print that old event in updateListener ,i am getting null every time.
EPServiceProvider sp = EPServiceProviderManager.getDefaultProvider();
String qry = "select count(*) from com.bizruntime.Student.win:length(2)";
EPStatement statement = sp.getEPAdministrator().createEPL(qry);
MyListener listener = new MyListener();
statement.addListener(listener);
Student student1 = new Student(44,"xyz");
Student student2= new Student(45,"pqr");
Student student3 = new Student(43,"stu");
Student student4 = new Student(41,"abc");
sp.getEPRuntime().sendEvent(student1);
sp.getEPRuntime().sendEvent(student2);
sp.getEPRuntime().sendEvent(student3);
sp.getEPRuntime().sendEvent(student4);
this is listener class:
public void update(EventBean[] newEvent, EventBean[] oldEvent) {
EventBean event = newEvent[0];
System.out.println(oldEvent);
System.out.println("Student Name :"+event.get("count(*)"));
}
There is a "select rstream" which gives you the "remove stream" matching what is in your select clause. If the select clause is just a count then the remove stream is the previous count. In the case when you also need some event output you could looks the event aggregation functions like "last" or "window" or at the functions "prev" and "prior".