Esper事件处理引擎_17_EPL 语法_9_Schema 声明数据类型

官方地址:http://www.espertech.com


Esper 事件引擎栏目:http://blog.csdn.net/xiaohulunb/article/category/2436609


EPL 语法代码见-GitHub代码地址:点击打开链接


涉及 Javabean,Listener,main 以 GitHub 包下为最新更,注释解释排版有问题可参考源码


EPL_9_Schema


package com.framework_technology.esper.epl;

import com.java.annotation.document.Keyword;
import com.java.annotation.document.Undigested;

/**
 * API - 5.16. Declaring an Event Type: Create Schema
 *
 * @author wei.Li by 14-8-21.
 */
public class EPL_9_Schema {

    /**
     * 声明一个提供事件类型的名称和数据类型
     * <p>
     * 语法:
     * <p>
     * create [map | objectarray] schema schema_name [as]
     * (property_name property_type [,property_name property_type [,...])
     * [inherits inherited_event_type[, inherited_event_type] [,...]]
     * [starttimestamp timestamp_property_name]
     * [endtimestamp timestamp_property_name]
     * [copyfrom copy_type_name [, copy_type_name] [,...]]
     * <p>
     * 1.任何Java类名,完全合格或引入简单的类名配置。
     * 2.添加左右方括号[]到任何类型来表示一个数组类型的事件属性。
     * 3.使用事件类型名称作为属性类型。
     * <p>
     *
     * @return epl[]
     */
    protected static String declareSchema() {
        // Declare type SecurityEvent
        String epl1 = "create schema SecurityEvent as (ipAddress string, userId String, numAttempts int)";

        // 声明指定字段名称和数据类型 与 POJO[hostinfo]
        String epl2 = "create schema AuthorizationEvent(group String, roles String[], hostinfo com.mycompany.HostNameInfo)";

        // 声明一个有其他 schema 数组类型的字段innerEvents
        String epl3 = "create schema CompositeEvent(group String, innerEvents SecurityEvent[])";

        // 声明类型WebPageVisitEvent继承自PageHitEvent所有属性
        @Keyword(keyWord = "inherits", Description = "继承")
        String epl4 = "create schema WebPageVisitEvent(userId String) inherits PageHitEvent";

        // 声明一个类型的起始和结束时间戳(即事件与持续时间)(i.e. event with duration)
        String epl5 = "create schema RoboticArmMovement (robotId string, startts long, endts long)" +
                "starttimestamp startts endtimestamp endts";

        //创建具有SecurityEvent的所有属性加一个用户名属性类型
        @Keyword(keyWord = "copyfrom", Description = "复制")
        String epl6 = "create schema ExtendedSecurityEvent (userName string) copyfrom SecurityEvent";

        //创建具有SecurityEvent的所有属性类型
        String epl7 = "create schema SimilarSecurityEvent () copyfrom SecurityEvent";

        //创建具有SecurityEvent和WebPageVisitEvent的所有属性加一个用户名属性类型
        String epl8 = "create schema WebSecurityEvent (userName string) copyfrom SecurityEvent, WebPageVisitEvent";

        // 显示完整的包名 LoginEvent event type
        String epl9 = "create schema LoginEvent as com.mycompany.LoginValue";

        // 当把包名配置后,无需加包名
        String epl10 = "create schema LogoutEvent as SignoffValue";

        return epl1;
    }

    /**
     * 使用实例
     *
     * @return epl
     */
    protected static String useSchema() {
        String epl1 = "create schema SecurityData (name String, roles String[])";
        String epl2 = "create window SecurityEvent.win:time(30 sec) " +
                " (ipAddress string, userId String, secData SecurityData, historySecData SecurityData[])";

        return epl1;
    }

}


转载于:https://my.oschina.net/huluerwa/blog/311322

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值