Following are the supported inbuilt windows of Siddhi
time
Syntax | <event> time(<int|long|time> windowTime) |
---|
Extension Type | Window |
---|
Description | A sliding time window that holds events that arrived during the last windowTime period at a given time, and gets updated for each event arrival and expiry. |
---|
Parameter | windowTime : The sliding time period for which the window should hold events.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | |
---|
timeBatch
Syntax | <event> timeBatch(<int|long|time> windowTime) |
---|
Extension Type | Window |
---|
Description | A batch (tumbling) time window that holds events that arrive during windowTime periods, and gets updated for each windowTime . |
---|
Parameter | windowTime : The batch time period for which the window should hold events. |
---|
Return Type | Returns current and expired events. |
---|
Examples | timeBatch(20) for processing events that arrive every 20 milliseconds.timeBatch(2 min) for processing events that arrive every 2 minutes.
|
---|
length
Syntax | <event> length(<int> windowLength) |
---|
Extension Type | Window |
---|
Description | A sliding length window that holds the last windowLength events at a given time, and gets updated for each arrival and expiry. |
---|
Parameter | windowLength : The number of events that should be included in a sliding length window.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | length(10) for processing the last 10 events.length(200 ) for processing the last 200 events.
|
---|
lengthBatch
Syntax | <event> lengthBatch(<int> windowLength) |
---|
Extension Type | Window |
---|
Description | A batch (tumbling) length window that holds a number of events specified as the windowLength . The window is updated each time a batch of events that equals the number specified as the windowLength arrives. |
---|
Parameter | windowLength : The number of events the window should tumble. |
---|
Return Type | Returns current and expired events. |
---|
Examples | lengthBatch(10) for processing 10 events as a batch.lengthBatch(200) for processing 200 events as a batch.
|
---|
externalTime
Syntax | <event> externalTime(<long> timestamp, <int|long|time> windowTime) |
---|
Extension Type | Window |
---|
Description | A sliding time window based on external time. It holds events that arrived during the last windowTime period from the external timestamp, and gets updated on every monotonically increasing timestamp. |
---|
Parameter | windowTime : The sliding time period for which the window should hold events.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | externalTime(eventTime,20) for processing events arrived within the last 20 milliseconds from the eventTime externalTime(eventTimestamp, 2 min) for processing events arrived within the last 2 minutes from the eventTimestamp
|
---|
cron
Syntax | <event> cron(<string> cronExpression) |
---|
Extension Type | Window |
---|
Description | This window returns events processed periodically as the output in time-repeating patterns, triggered based on time passing. |
---|
Parameter | cronExpression : cron expression that represents a time schedule. |
---|
Return Type | Returns current and expired events. |
---|
Examples | cron('*/5 * * * * ?') returns processed events as the output every 5 seconds. |
---|
firstUnique
Syntax | <event> firstUnique(<string> attribute) |
---|
Extension Type | Window |
---|
Description | First unique window processor keeps only the first events that are unique according to the given unique attribute. |
---|
Parameter | attribute : The attribute that should be checked for uniqueness. |
---|
Return Type | Returns current and expired events. |
---|
Examples | firstUnique(ip) returns the first event arriving for each unique ip . |
---|
unique
Syntax | <event> unique(<string> attribute) |
---|
Extension Type | Window |
---|
Description | This window keeps only the latest events that are unique according to the given unique attribute. |
---|
Parameter | attribute : The attribute that should be checked for uniqueness. |
---|
Return Type | Returns current and expired events. |
---|
Examples | unique(ip) returns the latest event that arrives for each unique ip . |
---|
sort
Syntax | <event> sort(<int> windowLength)
<event> sort(<int> windowLength, <string> attribute, <string> order)
<event> sort(<int> windowLength, <string> attribute, <string> order, .. , <string> attributeN, <string> orderN)
|
---|
Extension Type | Window |
---|
Description | This window holds a batch of events that equal the number specified as the windowLength and sorts them in the given order. |
---|
Parameter | attribute : The attribute that should be checked for the order.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | sort(5, price, 'asc') keeps the events sorted by price in the ascending order. Therefore, at any given time, the window contains the 5 lowest prices. |
---|
frequent
Syntax | <event> frequent(<int> eventCount)
<event> frequent(<int> eventCount, <string> attribute, .. , <string> attributeN)
|
---|
Extension Type | Window |
---|
Description | This window returns the latest events with the most frequently occurred value for a given attribute(s). Frequency calculation for this window processor is based on Misra-Gries counting algorithm. |
---|
Parameter | eventCount : The number of most frequent events to be emitted to the stream.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | frequent(2) returns the 2 most frequent events.frequent(2, cardNo) returns the 2 latest events with the most frequently appeared card numbers.
|
---|
lossyFrequent
Syntax | <event> lossyFrequent(<double> supportThreshold, <double> errorBound)
<event> lossyFrequent(<double> supportThreshold, <double> errorBound, <string> attribute, .. , <string> attributeN)
|
---|
Extension Type | Window |
---|
Description | This window identifies and returns all the events of which the current frequency exceeds the value specified for the supportThreshold parameter. |
---|
Parameters | errorBound : The error bound value.attribute : The attributes to group the events. If no attributes are given, the concatenation of all the attributes of the event is considered.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | lossyFrequent(0.1, 0.01) returns all the events of which the current frequency exceeds 0.1 , with an error bound of 0.01 .lossyFrequent(0.3, 0.05, cardNo) returns all the events of which the cardNo attributes frequency exceeds 0.3 , with an error bound of 0.05 .
|
---|
externalTimeBatch
Syntax | <event> externalTimeBatch(<long> timestamp, <int|long|time> windowTime) |
---|
Extension Type | Window |
---|
Description | A batch (tumbling) time window based on external time, that holds events arrived during windowTime periods, and gets updated for every windowTime . |
---|
Parameters | timestamp : The time which the window determines as current time and will act upon. The value of this parameter should be monotonically increasing.windowTime : The batch time period for which the window should hold events.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | externalTimeBatch(eventTime,20) for processing events that arrive every 20 milliseconds from the eventTime .externalTimeBatch(eventTimestamp, 2 min ) for processing events that arrive every 2 minutes from the eventTimestamp.
|
---|
timeLength
Syntax | <event> timeLength(<int|long|time> windowTime, <int> windowLength) |
---|
Extension Type | Window |
---|
Description | A sliding time window that, at a given time holds the last windowLength events that arrived during last windowTime period, and gets updated for every event arrival and expiry. |
---|
Parameters | windowTime : The sliding time period for which the window should hold events.windowLength : The number of events that should be be included in a sliding length window.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | timeLength(20 sec, 10) for processing the last 10 events that arrived within the last 20 seconds.timeLength(2 min, 5) for processing the last 5 events that arrived within the last 2 minutes.
|
---|