Search code examples
esper

Use Esper variable to grow and shrink a time window


I have a time window and a variable that is the parameter to the time window.

CREATE VARIABLE int expireSecs = 10;
SELECT * FROM Event#time(expireSecs sec);

In the code I call to set the expireSecs value.

epRuntime.setVariableValue("expireSecs", 5);

The time window doesn't seems to go from 10 seconds to 5 seconds.


Solution

  • The expression-window and expression-batch-window are the only windows that re-evaluate parameters expressions continuously. The time window does not re-evaluate. The documentation has this here. There is an example in the expression-window description, in this way.

    select * from MyEvent#expr(oldest_timestamp > newest_timestamp - (1000*expirySec))