Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

Siddhi Inbuilt windows in wiki format

Following are the supported inbuilt windows of Siddhi

Table of Contents
maxLevel3
minLevel3

time
Anchor
time
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

...

  • time(20) for processing events that arrived

...

  • within the last 20 milliseconds.

...

  • time(2 min)

...

  • for processing events that arrived

...

  • within the last 2 minutes.

...

...

timeBatch
Anchor
timeBatch
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
Anchor
length
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
Anchor
lengthBatch
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
Anchor
externalTime
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 TypeReturns 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
Anchor
cron
cron

Syntax<event> cron(<string> cronExpression)
Extension TypeWindow
DescriptionThis window returns events processed periodically as the output in time-repeating patterns, triggered based on time passing.
ParametercronExpression:

...

cron expression that represents a time schedule.
Return TypeReturns current and expired events.
Examplescron('*/5 * * * * ?') returns processed events as the output every 5 seconds.

firstUnique
Anchor
firstUnique
firstUnique
 

Syntax<event> firstUnique(<string> attribute)
Extension TypeWindow
DescriptionFirst 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 TypeReturns current and expired events.
ExamplesfirstUnique(ip) returns the first event arriving for each unique ip.

unique
Anchor
unique
unique

Syntax <event>  unique (<string>  attribute )
Extension TypeWindow
DescriptionThis 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 TypeReturns current and expired events.
Examplesunique(ip) returns the latest event that arrives for each unique ip.

sort
Anchor
sort
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 TypeWindow
DescriptionThis 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 TypeReturns current and expired events.
Examplessort(5, volume, 'asc', price, 'desc') returns the events sorted in ascending order of volume, and descending order of price for a window of 5 events.

frequent
Anchor
frequent
frequent

Syntax

<event> frequent(<int> eventCount)

<event> frequent(<int> eventCount, <string> attribute, .. , <string> attributeN)

Extension TypeWindow
DescriptionThis 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 TypeReturns 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
Anchor
lossyFrequent
lossyFrequent

Syntax

<event> lossyFrequent(<double> supportThreshold, <double> errorBound)

<event> lossyFrequent(<double> supportThreshold, <double> errorBound, <string> attribute, .. , <string> attributeN)

Extension TypeWindow
DescriptionThis 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 TypeReturns 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 TypeWindow
DescriptionA 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 TypeWindow
DescriptionA 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 TypeReturns 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
Excerpt
hiddentrue

To do:

...