功能:该语法是针对所查询事件中的属性又是另一种属性的查询结果控制。
格式:
1 | "+j); |
19 | bean.setBean(item); |
20 | list.add(bean); |
21 | } |
22 | |
23 | orderArray ary = new orderArray(); |
24 | ary.setOrderBeans(list); |
25 | event.setOrderAry(ary); |
26 | event.setOrderBeans(list); |
27 | |
28 | String epsql = "select * from orderEvent[orderAry.orderBeans][bean]"; |
29 | EPStatement epstate = epAdmin.createEPL(epsql); |
30 | epstate.addListener(new orderListener()); |
31 | |
32 | epRuntime.sendEvent(event); |
说明:
1、epl执行语句为 select * from orderEvent[orderAry.orderBeans] 表示查询orderEvent事件中orderAry事件属性字段中的orderBeans 事件,因为orderEvent与orderAry、orderAry与orderBeans都是有一种嵌套关系,就像类中有类一样是具有层次的;
2、epl执行语句为 select * from orderEvent[orderAry.orderBeans][bean] 表示只查询orderItem事件信息(bean为orderItem类型), 因为orderAry.orderBeans返回的是orderBean类型的数组,而orderItem又是orderBean的属性成员(bean与orderAry.orderBeans不在一个层面上),所以[orderAry.orderBeans][bean]表示的返回orderItem事件;
3、返回结果的数据格式,由各事件类的toString函数定义;
4、Contained-Event在join查询中,如果事件来自于named window,那么连接操作就必须加上unidirectional关键字,作用为每次连接操作的结果都独立起来;
示例:
1 | String join5 = "select count(*) from " + mediaOrder + "[books.book] as book unidirectional, " + mediaOrder |
2 | + "[items.item] as item where productId = bookId"; |
3 | String join4 = "select count(*) from " + mediaOrder + "[books.book] as book, " + mediaOrder |
4 | + "[items.item] as item where productId = bookId"; |
说明:
Join4中当发送两个同样的mediaOrder对象,聚合函数count是要累加,而join5不会;