Apama Documentation : Developing Apama Applications : EPL Streams: A Quick Tour : Processing events using streams : Using the short-form from statement
Using the short-form from statement
In the previous example, on line 16 of the code, the query used is very simple:
from r in ranges select r : range { print range.toString(); }
It merely selects the current item in the stream and co-assigns it to the variable range. This is a common use-case and the EPL provides an alternate, short-form version that can be used instead, as illustrated below.
from ranges: range { print range.toString(); }
To further simplify the code in the previous example, note that instead of declaring a ranges stream variable, you can place the expression for the stream (that is, service.init("S001",60.0)) directly inline, in the from statement:
from service.init("S001",60.0): range { print range.toString(); }
Hence, the monitor code in the example in the previous topic can be rewritten as follows:
12. monitor UsesTemperatureRangeService {
13. action onload() {
14. TemperatureRangeService service := new TemperatureRangeService;
15. TemperatureRange range;
16. from service.init("S001",60.0): range { print range.toString(); }
17. }
18. }
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback