esper(1)-窗口概述
阿新 • • 發佈:2019-03-11
bsp tro print span 圖片 inf per pru runt
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);
esper(1)-窗口概述