This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

R Extension

This extension allows you to include R within the Siddhi Query Language.

R function

Syntax

define function <function name>[<language name>] return <return type> {

   <operation of the function>

};
Extension TypeEval Script
DescriptionThe <operation of the function> is an operation of the <function name> that is defined in the <language name> language, and the output is returned in the <return Type> specified.
Parameters
  • function name: The name of the function.
  • language name: The language of the script. In this scenario, it should be R.
  • return type: The return type of the function (int, long, float, double, string, bool or object).
  • operation of the function: The logic of the function.
Example

define function concatFunction[R] return string {

   return(paste(data, collapse=""));

};

The above function takes n (variable) number of strings, concatenates them and returns the output. Input parameters are automatically input as an array.

A stream can be defined as follows.

define stream TempStream(deviceID long, roomNo int, temp double);

The eval script defined above can be used in this stream as follows.

from TempStream

select concatFunction(roomNo,deviceID) as id, temp  

insert into DeviceTempStream;