将参数传递给 ESPER EPL 查询?

Pass parameter to ESPER EPL query?

我是 esper epl 的新手 query.I 想知道是否可以在 运行 中更改 EPL 查询 time.It 意味着我有一个可以用来更改时间长度的表格,ESPER.It中的记录数就是这样,增加epl查询的时间长度,event.Likewise中的记录数我想更改pragmatically.I中的参数想知道这是否可能并且如果是,请给我一些开始的提示。 谢谢

根据您的实际需要,您可以使用Variables。 来自 Esper Docs

In addition to creating a variable via the create variable syntax, the runtime and engine configuration API also allows adding variables. The next code snippet illustrates the use of the runtime configuration API to create a string-typed variable:

epService.getEPAdministrator().getConfiguration().addVariable("myVar", String.class, "init value");

然后您可以 use variables 在您的查询中。例如(再次来自 Esper 文档):

The next statement assumes that a variable named 'var_threshold' was created to hold a total price threshold value. The statement outputs an event when the total price for a symbol is greater then the current threshold value:

 select symbol, sum(price) 
   from TickEvent  group by symbol having
   sum(price) > var_threshold

因此,如果您确切地知道要参数化的内容,那么您可以使查询更加动态。