首页 > 其他 > 详细

esper(1)-窗口概述

时间:2019-03-11 17:36:26      阅读:320      评论:0      收藏:0      [点我收藏+]

 

 

技术分享图片

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

原文:https://www.cnblogs.com/yaoyuan2/p/10511944.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!