On-Merge With Named Windows
功能:对window中的insert、update、delete操作进行组合运用。
格式:
1 | "; |
14 | |
15 | System.out.println("start Name Window select"); |
16 | EPOnDemandQueryResult sResult=epRuntime.executeQuery(select); |
17 | EventBean[] arryBeans =sResult.getArray(); |
18 | for (EventBean bean:arryBeans){ |
19 | System.out.println("select:"+bean.getUnderlying()); |
20 | } |
21 | |
22 | System.out.println("start Name Window update"); |
23 | EPOnDemandQueryResult uResult=epRuntime.executeQuery(update); |
24 | arryBeans =uResult.getArray(); |
25 | for (EventBean bean:arryBeans){ |
26 | System.out.println("select:"+bean.getUnderlying()); |
27 | } |
28 | |
29 | System.out.println("start Name Window delete"); |
30 | EPOnDemandQueryResult dResult=epRuntime.executeQuery(delete); |
31 | arryBeans =dResult.getArray(); |
32 | for (EventBean bean:arryBeans){ |
33 | System.out.println("select:"+bean.getUnderlying()); |
34 | } |
Explicitly Indexing Named Windows
功能:对Named Window中存放的事件属性建立索引。
格式:
1 | create [unique] index index_name on window_or_table_name (property [hash|btree] |
2 | [, property] [hash|btree] [,...] ) |
格式说明:
1、Unique:表示建立唯一索引,如果插入了重复的行,则会抛出异常并阻止重复行插入。如果不使用此关键字,则表示可以插入重复行;
2、Index_name:索引名称;
3、后面的括号中包含named window中的属性以及索引类型。索引类型分两种,hash索引不会排序,如果有=操作,建议使用此类型索引。btree索引基于排序二叉树,适合<, >, >=, <=, between, in等操作。如果不显式声明hash或者btree,则默认为hash索引;
Dropping or Removing Named Windows
功能:
注销named window,方式是直接调用EPStatement对象的destroy方法。虽然注销,但是named window的名字仍然被占用着,所以你只能重新建立和之前的named window一样结构的window,否则会抛出异常
示例子:
1 | // Create DropWindow |
2 | create window DropWindow.win:keepall() as select * from DropEvent |
3 | |
4 | // Destroy DropWindow |
5 | EPStatement state = admin.createEPL("create window DropWindow.win:keepall() as select * from DropEvent"); |
6 | state.destroy(); |
7 | |
8 | // Create DropEvent again(different with prior epl) |
9 | create window DropWindow.win:keepall() as select name from DropEvent |
10 | // throw Exception |