Apama Documentation : Developing Apama Applications : EPL Streams: A Quick Tour : Common stream query patterns : Retaining the most recent item in each partition of a partitioned stream
Retaining the most recent item in each partition of a partitioned stream
There are some situations where you want to join the most recent events from two sources, based on a common key. Typically you are processing all events from those sources and not a subset of those events. This pattern is similar to the previous example, but with a partition by clause added to each leg of the join.
01. event Temperature { string sensorId; float temperature; }
02. event Pressure { string sensorId; float pressure; }
03. event TemperatureAndPressure { string sensorId; float temperature;
04. float pressure; }
05. monitor CombineTheLatestTemperatureAndPressureReadings {
06. action onload() {
07. TemperatureAndPressure tp;
08. from t in all Temperature() partition by t.sensorId retain 1
09. join p in all Pressure() partition by p.sensorId retain 1
10. on t.sensorId equals p.sensorId
11. select TemperatureAndPressure(t.sensorId, t.temperature,
12. p.pressure) : tp {
13. print tp.toString();
14. }
15. }
16. }
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback