Apama Documentation : Developing Apama Applications : EPL Streams: A Quick Tour : Processing events using streams : Creating a stream network
Creating a stream network
The code example below implements the simple stream network illustrated in About the Apama event stream processing model . The code illustrates that stream queries can be used in from statements and also on the right side of a stream assignment. Executing a stream assignment statement does two things:
*Creates the defined query within the stream network.
*Updates the stream variable (on the left side of the assignment) to refer to the stream query's output stream.
Up to now, streams have been referred to as event streams. In Apama, the type of a stream need not be an event; it is possible to create streams of simple types such as decimal, float, integer, boolean, and string.3
01. TemperatureAndPressure tp;
02. stream<Temperature> temperatures := all Temperature(sensorId="T001");
03. stream<Pressure> pressures := all Pressure(sensorId="P001");
04. stream<float> meanTs := from t in temperatures
05. retain 3 select mean(t.temperature);
06. stream<float> meanPs := from p in pressures
07. retain 3 select mean(p.pressure);
08. from t in meanTs retain 1 from p in meanPs retain 1
09. select TemperatureAndPressure("S001",t,p) : tp {
10. print tp.toString();
11. }
Line 8 of the code example shows one method for joining two streams. The stream query contains two from clauses, where each from clause specifies that the most recent item in the stream is retained. A query with two from clauses identifies that a cross-join operation should be performed between the two source item sets. In the code example, when a new item is available on the meanPs stream, it is joined with the most recent item on the meanTs stream, and when a new item is available on the meanTs stream, it is joined with the most recent item on the meanPs stream.
3 It is for this reason that, in Developing Apama Applications in EPL, and in other documentation, the contents of streams are referred to as items, not as events.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback