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, <int> startTime) |
---|
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. startTime (Optional): This specifies an offset in milliseconds in order to start the window at a time different to the standard time.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | timeBatch(20) processes events that arrive every 20 milliseconds.timeBatch(2 min) processes events that arrive every 2 minutes.timeBatch(10 min, 0) processes events that arrive every 10 minutes starting from the 0th minute. e.g., If you deploy your window at 08:22 and the first event arrives at 08:26, this event occurs within the time window 08.20 - 08.30. Therefore, this event is emitted at 08.30. timeBatch(10 min, 1000*60*5) processes events that arrive every 10 minutes starting from 5th minute. e.g., If you deploy your window at 08:22 and the first event arrives at 08:26, this event occurs within the time window 08.25 - 08.35. Therefore, this event is emitted at 08.35.
|
---|
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, <int|long|time> startTime, <int|long|time> timeout) |
---|
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.- startTime (Optional): User defined start time. This could either be a constant (of type int, long or time) or an attribute of the corresponding stream (of type long). If an attribute is provided, initial value of attribute would be considered as startTime. When startTime is not given, initial value of timestamp is used as the default.
- timeout (Optional): Time to wait for arrival of new event, before flushing and giving output for events belonging to a specific batch. If timeout is not provided, system waits till an event from next batch arrives to flush current batch.
|
---|
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. externalTimeBatch(eventTimestamp, 2 sec, 0 ) for processing events that arrive every 2 seconds from the eventTimestamp. Starts on 0th millisecond of an hour. externalTimeBatch(eventTimestamp, 2 sec, eventTimestamp, 100 ) for processing events that arrive every 2 seconds from the eventTimestamp. Considers the first event's eventTimestamp value as startTime. Waits 100 milliseconds for the arrival of a new event before flushing current batch.
|
---|
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.
|
---|
uniqueExternalTimeBatch
Syntax | <event> uniqueExternalTimeBatch(<string> attribute, <long> timestamp, <int|long|time> windowTime, <int|long|time> startTime, <int|long|time> timeout, <bool> replaceTimestampWithBatchEndTime ) |
---|
Extension Type | Window |
---|
Description | A batch (tumbling) time window based on external time that holds latest unique events that arrive during the windowTime periods, and gets updated for each windowTime . |
---|
Parameters | attribute : The attribute that should be checked for uniqueness.timestamp : The time considered as the current time for the window to act upon. The value of this parameter should be monotonically increasing.windowTime : The batch time period for which the window should hold events.startTime (Optional): The user-defined start time. This can either be a constant (of the int , long or time type) or an attribute of the corresponding stream (of the long type). If an attribute is provided, the initial value of this attribute is considered as the startTime . When the startTime is not given, the initial value of the timestamp is used by default.timeout (Optional): The time duration to wait for the arrival of new event before flushing and giving output for events belonging to a specific batch. If the timeout is not provided, the system waits untill an event from next batch arrives to flush the current batch.replaceTimestampWithBatchEndTime (Optional): Replaces the timestamp value (That is pointed by the 2nd parameter) with the corresponding batch end time stamp.
|
---|
Return Type | Returns current and expired events. |
---|
Examples | uniqueExternalTimeBatch(ip, eventTime, 20) processes unique events based on the ip attribute that arrive every 20 milliseconds from the eventTime .uniqueExternalTimeBatch(ip, eventTimestamp, 2 min ) processes unique events based on the ip attribute that arrive every 2 minutes from the eventTimestamp .uniqueExternalTimeBatch(ip, eventTimestamp, 2 sec, 0 ) processes unique events based on the ip attribute that arrive every 2 seconds from the eventTimestamp . It starts on 0th millisecond of an hour.uniqueExternalTimeBatch(ip, eventTimestamp, 2 sec, eventTimestamp, 100 ) processes unique events based on the ip attribute that arrive every 2 seconds from the eventTimestamp . It considers the eventTimestamp value of the first event as startTime , and waits 100 milliseconds for the arrival of a new event before flushing current batch.
uniqueExternalTimeBatch(ip, eventTimestamp, 2 sec, eventTimestamp, 100, true ) processes unique events based on the ip attribute that arrive every 2 seconds from the eventTimestamp . It considers the eventTimestamp value of the first event as startTime , and waits 100 milliseconds for the arrival of a new event before flushing current batch. Here, the value for eventTimestamp is replaced with the timestamp of the batch end.
|
---|