Time Window:
Length Window:
Time Batch Window:
带batch的是所有的都执行完后,在触发UpdateListener,如下边例子:
public class AppleListener implements UpdateListener { public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null) { Double avg = (Double)newEvents[0].get("avg(price)"); System.out.println("Apple‘s average price is " + avg); } } }
String product = Apple.class.getName(); String epl = "select avg(price) from " + product + ".win:length_batch(3)"; EPStatement state = admin.createEPL(epl); state.addListener(new AppleListener()); EPRuntime runtime = epService.getEPRuntime(); Apple apple1 = new Apple(); apple1.setId(1); apple1.setPrice(5); runtime.sendEvent(apple1); Apple apple2 = new Apple(); apple2.setId(2); apple2.setPrice(2); runtime.sendEvent(apple2); Apple apple3 = new Apple(); apple3.setId(3); apple3.setPrice(5); runtime.sendEvent(apple3);
原文:https://www.cnblogs.com/yaoyuan2/p/10511944.html