如何在esper中获得旧事件?
how to get an old event in esper?
我正在 Esper.But 中做一个长度为 window 的程序,当 window 已满时,之前的事件应该变成旧的 event.When 我正在尝试在 updateListener 中打印那个旧事件,我每次都得到 null。
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);
这是监听器class:
public void update(EventBean[] newEvent, EventBean[] oldEvent) {
EventBean event = newEvent[0];
System.out.println(oldEvent);
System.out.println("Student Name :"+event.get("count(*)"));
}
有一个 "select rstream" 可以为您提供与 select 子句中的内容相匹配的 "remove stream"。如果 select 子句只是一个计数,那么删除流就是之前的计数。如果您还需要一些事件输出,您可以查看事件聚合函数,如 "last" 或 "window" 或函数 "prev" 和 "prior".
我正在 Esper.But 中做一个长度为 window 的程序,当 window 已满时,之前的事件应该变成旧的 event.When 我正在尝试在 updateListener 中打印那个旧事件,我每次都得到 null。
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);
这是监听器class:
public void update(EventBean[] newEvent, EventBean[] oldEvent) {
EventBean event = newEvent[0];
System.out.println(oldEvent);
System.out.println("Student Name :"+event.get("count(*)"));
}
有一个 "select rstream" 可以为您提供与 select 子句中的内容相匹配的 "remove stream"。如果 select 子句只是一个计数,那么删除流就是之前的计数。如果您还需要一些事件输出,您可以查看事件聚合函数,如 "last" 或 "window" 或函数 "prev" 和 "prior".