Apama Documentation : Developing Apama Applications : EPL Streams: A Quick Tour : Processing events using streams : Using windows in stream queries
Using windows in stream queries
Various examples in earlier sections have used window operators. Within a stream query, when a window operator is applied to a stream, it causes some of the past items in the stream to be retained. These are the items upon which the relational query operations are performed. For example, consider the following query:
from t in all Temperature(sensorId="T001") retain 10 select mean(t.temperature)
For sensor "T001", this query calculates the mean temperature value from the set of the most recent 10 temperature readings from that sensor. Now consider the following query:
from t in all Temperature(sensorId="T001") within 60.0 select mean(t.temperature)
For sensor "T001", this query calculates the mean temperature value from the set of all temperature readings for that sensor within the last 60.0 seconds.
The table below gives a guide to the window operators and their combinations:
Syntax
Description
retain all
Retains all of the items input to the stream since its creation. 9
retain number
Retains (up to) the number of most recent items input to the stream.
within duration
Retains all items input to the stream within the last duration seconds.
within duration retain number
Retains (up to) the number of most recent items input to the stream within the last duration seconds.
retain number with unique key
Retains (up to) the number of most recent items input to the stream. A new item with a given key value will displace an existing item with the same key value.
within duration with unique key
Retains items input to the stream within the last duration seconds. A new item with a given key value will displace an existing item with the same key value.
If no window operator is applied to a stream then the set of items on which the relational query operations are performed is the set of items that is current for the stream. Using a stream without applying any window operations to it can be useful when used within a join query.
9 The implementation achieves this behavior without actually retaining all of the items.
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback