Following are the supported inbuilt windows of Siddhi
time
<event> time(<int|long|time>
windowTime)
- Extension Type: Window
- Description: Sliding time window, that holds events for that arrived during last windowTime period, and gets updated on every event arrival and expiry.
- Parameter: windowTime: The sliding time period for which the window should hold events.
- Return Type: Return current and expired events.
- Examples:
time(20)
for processing events arrived in last 20 milliseconds.time(2 min)
for processing events arrived in last 2 minutes.
timeBatch
<event> timeBatch(<int|long|time>
windowTime)
- Extension Type: Window
- Description: Batch (tumbling) time window, that holds events arrived between windowTime periods, and gets updated for every windowTime.
- Parameter: windowTime: The batch time period for which the window should hold events.
- Return Type: Return current and expired events.
- Examples:
timeBatch(20)
for processing events arrived every 20 milliseconds.timeBatch(2 min)
for processing events arrived every 2 minutes.
length
<event> length(<int>
windowLength)
- Extension Type: Window
- Description: Sliding length window, that holds last windowLength events, and gets updated on every event arrival and expiry.
- Parameter: windowLength: The number of events that need to should be in a sliding length window.
- Return Type: Return current and expired events.
- Examples:
length(10)
for processing last 10 events.length(200)
for processing last 200 events.
lengthBatch
<event> lengthBatch(<int>
windowLength)
- Extension Type: Window
- Description: Batch (tumbling) length window, that holds up to windowLength events, and gets updated on every windowLength event arrival.
- Parameter: windowLength: For the number of events the window should tumble.
- Return Type: Return current and expired events.
- Examples:
lengthBatch(10)
for processing 10 events as a batch.lengthBatch(200)
for processing 200 events as a batch.
externalTime
<event> time(<long> timestamp, <int|long|time>
windowTime)
- Extension Type: Window
- Description: Sliding time window based on external time, that holds events for that arrived during last windowTime period from the external timestamp, and gets updated on every monotonically increasing timestamp.
- Parameter: timestamp: The time which the window determines as current time and will act upon, the value of this parameter should be monotonically increasing.
- Parameter: windowTime: The sliding time period for which the window should hold events.
- Return Type: Return current and expired events.
Examples:
externalTime(eventTime,20)
for processing events arrived in last 20 milliseconds from the eventTime.externalTime(eventTimestamp, 2 min)
for processing events arrived in last 2 minutes from eventTimestamp.
cron
<event> cron(<string> cronExpression)
- Extension Type: Window
- Description: Cron window will output processed events periodically in a time-repeating patterns, that triggers based on time passing.
- Parameter: cronExpression: cron expression that represents a time schedule.
- Return Type: Return current and expired events.
- Examples: cron('*/5 * * * * ?') will output processed events every 5 seconds.
firstUnique
<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: attribute that should be checked for uniqueness.
- Return Type: Return current and expired events.
- Examples: firstUnique(ip) will return first event arriving for each unique ip.
unique
<event> unique(<string> attribute)
- Extension Type: Window
- Description: Unique window processor keeps only the latest events that are unique according to the given unique attribute.
- Parameter: attribute: attribute that should be checked for uniqueness.
- Return Type: Return current and expired events.
- Examples: unique(ip) will return latest event arriving for each unique ip.
sort
<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: Sort Processor will holds up to windowLength events and sort them in a given order.
- Parameter: windowLength: for the number of events the window should tumble.
- Parameter: attribute: attribute that should be checked for the order.
- Parameter: order: order of the attribute defined by "asc" or "desc". If neither "asc" nor "desc" is given for a certain attribute, order defaults to "asc".
- Return Type: Return 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
<event> frequent(<int> eventCount)
<event> frequent(<int> eventCount, <string> attribute, .. , <string> attributeN)
- Extension Type: Window
- Description: Frequent window processor will return 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: number of most frequent events to be emitted to the stream
- Parameter: attribute: attributes to group the events. If no attributes are given, the concatenation of all the attributes of the event will be considered.
- Return Type: Return current and expired events.
- Examples: frequent(2) will return the 2 most frequent events. frequent(2, cardNo) will return 2 latest events with the most frequently appeared card numbers.
lossyFrequent
<event> lossyFrequent(<double> supportThreshold, <double> errorBound)
<event> lossyFrequent(<double> supportThreshold, <double> errorBound, <string> attribute, .. , <string> attributeN)
- Extension Type: Window
- Description: Lossy frequent window processor will identify and return all events whose current frequency exceeds supportThreshold. Frequency calculation for this window processor is based on Lossy Counting algorithm.
- Parameter: supportThreshold: support threshold value
- Parameter: errorBound: error bound value
- Parameter: attribute: attributes to group the events. If no attributes are given, the concatenation of all the attributes of the event will be considered.
- Return Type: Return current and expired events.
- Examples: lossyFrequent(0.1, 0.01) will return all the events whose current frequency exceeds 0.1, with a error bound of 0.01. lossyFrequent(0.3, 0.05, cardNo) will return all the events whose cardNo attribute's frequency exceeds 0.3, with a error bound of 0.05.