Versions Compared

Key

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

Siddhi Inbuilt functions windows in wiki format

Following are the supported inbuilt functions windows of Siddhi

...

Table of Contents

...

time
Anchor

...

time

...

time

<event> time (<int|long|float|double|string|bool|object >  arg1<int|long|float|double|string|bool|object > arg2,.., <int|long|float|double|string|bool|object > argNtime>  windowTime)

  • Extension TypeFunction 
  • Description: Returns the value of the first non null input parameter.
  • Parameters: This function accepts one or more parameters, and they all have to be the same type of, any one of the available types.
  • Return Type: Return type will be the first input parameter's type.
  • Examplescoalesce('123', null, '789') returns '123'. coalesce(null, 76, 567) returns 76. coalesce(null, null, null) returns null. 

...

< int|long|float|double|string|bool > convert (<int|long|float|double|string|bool>  toBeConverted<string> convertedTo)

  • Extension TypeFunction 
  • Description: Converts the first input parameter according to the convertedTo parameter. 
  • Parameter: toBeConverted : To be converted parameter with type other than object.
  • Parameter: convertedTo : A string constant parameter expressing the everted to type using one of the following strings values: 'int', 'long', 'float', 'double', 'string', 'bool'.
  • Return Type: Return type will be type specified by the convertedTo parameter.
  • Examplesconvert('123', 'double') returns 123.0. convert(45.9, 'int') returns 46. convert(true, 'string') returns 'true'. 

...

< bool > instanceOfBoolean (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Boolean or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Boolean and false otherwise.
  • ExamplesinstanceOfBoolean(123) returns false. instanceOfBoolean(true) returns true. instanceOfBoolean(false) returns true. 

...

< bool > instanceOfDouble (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Double or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Double and false otherwise.
  • ExamplesinstanceOfDouble(123) returns false. instanceOfDouble(56.45) returns true. instanceOfDouble(false) returns false. 

...

< bool > instanceOfFloat (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Float or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Float and false otherwise.
  • ExamplesinstanceOfFloat(123) returns false. instanceOfFloat(56.45) returns false. instanceOfFloat(56.45f) returns true. 

...

< bool > instanceOfInteger (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Integer or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Integer and false otherwise.
  • ExamplesinstanceOfInteger(123) returns true. instanceOfInteger(56.45) returns false. instanceOfInteger(56.45f) returns false. 

...

< bool > instanceOfLong (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of Long or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of Long and false otherwise.
  • ExamplesinstanceOfLong(123) returns false. instanceOfLong(5667l) returns true. instanceOfLong(56.67) returns false. 

...

< bool > instanceOfString (<int|long|float|double|string|bool|object>  arg)

  • Extension TypeFunction 
  • Description: Checks if the parameter is an instance of String or not. 
  • Parameter: arg : The parameter to be checked.
  • Return Type: Returns bool, true if the parameter is an instance of String and false otherwise.
  • ExamplesinstanceOfString('test') returns true. instanceOfString('5667') returns true. instanceOfString(56.67) returns false. 

UUID

< string > UUID ( )

  • Extension TypeFunction 
  • Description: Generate a UUID. 
  • Return Type: Returns a UUID string.
  • ExamplesUUID() returns a34eec40-32c2-44fe-8075-7f4fde2e2dd8. 

E.g. Converting room number to string and introducing message ID to each event

...

languagesql
linenumberstrue

...

  • Window 
  • Description: Sliding time window, that holds events for that arrived during last windowTime period, and gets updated on every event arrival and expiry.
  • ParameterwindowTime: The sliding time period for which the window should hold events.
  • Return Type: Return current and expired events.
  • Examplestime(20) for processing events arrived in last 20 milliseconds. time(2 min) for processing events arrived in last 2 minutes. 

timeBatch
Anchor
timeBatch
timeBatch

<event> timeBatch (<int|long|time>  windowTime)

  • Extension TypeWindow 
  • Description: Batch (tumbling) time window, that holds events arrived between windowTime periods, and gets updated for every windowTime.
  • ParameterwindowTime: The batch time period for which the window should hold events.
  • Return Type: Return current and expired events.
  • ExamplestimeBatch(20) for processing events arrived every 20 milliseconds. time(2 min) for processing events arrived every 2 minutes. 

length
Anchor
length
length

<event> length (<int>  windowLength)

  • Extension TypeWindow 
  • Description: Sliding length window, that holds last windowLength events, and gets updated on every event arrival and expiry.
  • ParameterwindowLength The number of events that need to should be in a sliding length window.
  • Return Type: Return current and expired events.
  • Exampleslength(10) for processing last 10 events. time(200) for processing last 200 events. 

lengthBatch
Anchor
lengthBatch
lengthBatch

<event> lengthBatch (<int>  windowLength)

  • Extension TypeWindow 
  • Description: Batch (tumbling) length window, that holds up to windowLength events, and gets updated on every windowLength event arrival.
  • ParameterwindowLength For the number of events the window should tumble.
  • Return Type: Return current and expired events.
  • ExampleslengthBatch(10) for processing 10 events as a batch. time(200) for processing 200 events as a batch. 

externalTime
Anchor
externalTime
externalTime

<event> time (<long> timestamp<int|long|time>  windowTime)

  • Extension TypeWindow 
  • 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.
  • Parametertimestamp The time which the window determines as current time and will act upon, the value of this parameter should be monotonically increasing. 
  • ParameterwindowTime: 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. 

    Excerpt
    hiddentrue

    To do: add other window types