在Esper中编写查询和用户定义的函数

时间:2016-08-11 07:12:08

标签: sequence complex-event-processing esper

我正在尝试创建一个EPL语句,以显示订单是否可行。

有两个事件,EventA(已处理)和EventB(未处理)。

create schema EventA(type string,percentCompleted integer);
create schema EventB(type string);

该语句应根据元素的类型(字符串)匹配所有已处理的元素。结果应包含一个布尔值,指示是否应处理订单。

我有以下声明在成功匹配时返回true(并且可以下订单)。但是,当无法下订单时,我还想要返回错误。

此处测试案例:
http://esper-epl-tryout.appspot.com/epltryout/mainform.html

   create schema EventA(type string, percentCompleted integer);  
   create schema EventB(type string);

   @Name('Out') select * from pattern [every a=EventA -> every  b=EventB(a.type = b.type AND a.percentCompleted > 20) ]

序列:

  EventA={type="1",percentCompleted=0}  
  EventA={type="2",percentCompleted=0}  
  EventA={type="1",percentCompleted=20}   
  EventA={type="1",percentCompleted=40}  
  EventB={type="1"}  

结果:(仅返回真实结果):

  Out-output={a={EventA={type='1', percentCompleted=40}}, b={EventB={type='1'}}}

我希望我的陈述返回TRUE和"输入"而不是整个结果,我也希望查询返回FALSE和"键入"当a.percentCompleted< 20。

1 个答案:

答案 0 :(得分:0)

完成百分比需要多长时间才能保持在20以下才能显示为FALSE?或者这个想法每次都是假的吗?无论哪种方式,您最简单的方法就是编写第二个EPL并附加相同的侦听器。要么是要么将查询写成连接。

相关问题