尝试使用Esper Lambda表达式

时间:2017-04-16 06:26:54

标签: java lambda esper

我正在尝试扩展where枚举方法的Esper文档中的示例,并遇到问题。以下是有问题的例子:

select items.where(i => i.location.x = 0 and i.location.y = 0) as zeroloc
from LocationReport

我想做的事情似乎很简单。而不是选择与此表达式匹配的items

  • 我想选择包含与表达式匹配的至少一个LocationReport的{​​{1}}个。

  • 在time_batch窗口上执行此操作(强调文本非批量时间窗口也是可能的。)

因此,每隔 n 秒,我会收到item个集合,其中每个报告的项目列表中至少包含一个零位置。

For Reference,以下是Esper示例中使用的Java对象的结构:

  

public class LocationReport {List items; ...

     

public class Item {String assetId; //乘客或行李资产   id位置位置; //(x,y)location boolean luggage; //   如果此项目是行李件,则为true StringIndPassenger; //如果   该项目是行李,包含乘客相关...

     

public class Location {int x; int y; ...

背景细节:假设LocationReport是我感兴趣的实际对象...
使用上面示例中的EPL,LocationReport逻辑工作,但问题是,在仅返回where成员时,我看不到它来自的items类,其中包含LocationReport以外的其他属性items需要。

另外,可能不相关,但在我的情况下,我收到很高的消息率,其中许多LocationReports是重复的(或者足够接近被认为是重复的),而我的where子句需要做出这个决定并且只能转发“新”消息。

谢谢!

1 个答案:

答案 0 :(得分:1)

您可以添加" *"选择,并给你事件对象。 select *, items.where(...) from LocationReport 您可以每隔N秒添加"输出"输出。添加" #time(...)"对于时间窗口。