I'm new to Esper and I'm trying to get the results of multiple EPStatements to run through the same UpdateListener. For instance:
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
EPStatement avgStatement = epService.getEPAdministrator()
.createEPL("select avg(price) from OrderEvent.win:time(30 sec)");
EPStatement sumStatement = epService.getEPAdministrator()
.createEPL("select sum(price) from OrderEvent.win:time(60 sec)");
Is it possible to combine the results of both of those EPStatements into a separate statement? Something like:
EPStatement bothStatements = epService.getEPAdministrator()
.createEPL("select * from avg(price), sum(price) where a.id=b.id");
bothStatements.addListener(listener);
I tried using inserting both statements into an Esper Named Window, but it seems like I can't do something like this where:
I would like to be able to combine the results of multiple statements and get a set of results (per event) into a single output stream.
Thanks for helping.
Did you consider that the same listener can be attached to two statements. What I means is "avgStatement.addListener(myListener)" and "sumStatement.addListener(myListener)".
As an alternative you can use insert-into to populate the same stream. The would be like "insert into MyStream select avg(price) as avgPrice, 0 as sumPrice from ..." and "insert into MyStream select 0 as avgprice, sum(price) as sumPrice from ...".
There is also the concept of a variant stream like variant types in visual basic. This lets you insert anything into a stream that is variant stream because variant streams don't need to be strongly typed.