R Language Extension
First you need to setup the prerequisites .
This extension allows you to execute R scripts within Siddhi query. Following are the functions of the R extension.
Evaluation function
Syntax | [<int|long|float|double|string|boolean>  output1 ,  <int|long|float|double|string|boolean>   output2, ... ] r:eval   ( <string > script,  <string >  outputAttributes, <int|long|float|double|string|boolean >  input1 , <int|long|float|double|string|boolean> input2 , ... ) |
---|---|
Extension Type | StreamProcessor |
Description | This runs the R script for each event and produces  aggregated outputs based on the provided input variable parameters and expected output attributes. |
Parameters | |
Return Parameters | Output parameters are generated based on the outputAttributes  provided. |
Example |
@info(name = 'query1') from dataIn#window.lengthBatch(2)#r:eval('totalItems <- sum(items); totalTemp <- sum(temp);', 'totalItems int, totalTemp double', items, temp) select * insert into dataOut; |
Â
Evaluation Source function
Syntax | [<int|long|float|double|string|boolean>  output1 ,  <int|long|float|double|string|boolean>   output2, ... ] r:eval   ( <string > filePath,  <string >  outputAttributes,<int|long|float|double|string|boolean>  input1 , <int|long|float|double|string|boolean> input2 , ... ) |
---|---|
Extension Type | Stream Processor |
Description | This runs the R script loaded from a file to each event and produces aggregated outputs based on the provided input variable parameters and expected output attributes. |
Parameters | |
Return | Output parameters are generated based on the outputAttributes  provided. |
Example |
@info(name = 'query1') from dataIn#window.lengthBatch(2)#r:evalSource('/home/user/test/script1.R', 'totalItems int, totalTemp double', items, temp) select * insert into dataOut; |