1. 程式人生 > >esper(1)-窗口概述

esper(1)-窗口概述

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)-窗口概述