【问题标题】:Access user defined method properties on query - Esper在查询中访问用户定义的方法属性 - Esper
【发布时间】:2021-11-08 21:02:50
【问题描述】:

我实现了一个查询,我从数据库中挖掘数据,但我必须更改它,所以我从我的代码中的自定义函数中挖掘我的数据。我阅读了文档并在配置中添加了注释导入。查询抛出该错误:

Failed to resolve event type, named window or table by name 'path.to.my.class.customfunction'

我不知道我的函数必须返回的类型,但我尝试了 Arraylist 和 Hashmaps,键为整数,值为自定义类,但没有成功。

我的最终查询希望如下所示:

select * from LocationEvent as loc,
                   ***CustomFuntion()*** as product
                        where loc.id=product.id  ;

我保留了用于数据库连接的结构。我不知道是否有其他方法可以解决这个问题。谢谢。

编辑:我设法使用该查询调用自定义函数:

select  path.to.class.getProducts() as product from pattern[every timer:interval(3 sec)]

我的函数现在返回一个 ArrayList,查询返回这个:

[Product{ProductID=124,.....,},Product{...}]

所以现在我的问题是我无法在查询中访问 Product 的属性,例如 products.ProductID

【问题讨论】:

    标签: java complex-event-processing esper


    【解决方案1】:

    如果你想在 from 子句中有一个自定义函数,你可以使用“method:”。文档在这里对此进行了描述:Accessing Non-Relational Data via Method。然后,Esper 运行时调用您的方法来获取事件/行。

    【讨论】:

    • 再次感谢您。那行得通。我无法完全理解 method: 和 not using this 之间的区别。我的意思是该方法现在如何查看返回数组的类的属性
    • "method:" 用于 from 子句。所有其他方法调用(不带“method:”)都可以在诸如 select/where/etc 的表达式中使用。
    • 好的,谢谢。文档很丰富。感谢您的信息
    猜你喜欢
    • 2018-10-25
    • 1970-01-01
    • 2017-05-10
    • 1970-01-01
    • 2021-12-31
    • 2018-03-25
    • 1970-01-01
    • 2014-01-21
    • 2014-11-06
    相关资源
    最近更新 更多