Skip to content

API Docs - v4.0.10

R

eval (Stream Processor)

R script Stream processor. This extension 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.

Syntax

r:eval(<STRING> script, <INT|LONG|FLOAT|DOUBLE|STRING|STRING> output.attributes, <INT|LONG|FLOAT|DOUBLE|STRING|STRING> input.attributes)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
script R script as a string produces aggregated outputs based on the provided input variable parameters and expected output attributes STRING No No
output.attributes A set of output attributes separated by commas as string. Each attribute is denoted as <name><space><type>. e.g., 'output1 string, output2 long' INT
LONG
FLOAT
DOUBLE
STRING
STRING
No No
input.attributes A set of input attributes separated by commas after output attributes. e.g., 'att1, att2' INT
LONG
FLOAT
DOUBLE
STRING
STRING
No No
Extra Return Attributes
Name Description Possible Types
outputParameters This runs the R script for each event and produces aggregated outputs based on the provided input variable parameters and expected output attributes. INT
LONG
FLOAT
DOUBLE
STRING
STRING

Examples EXAMPLE 1

@info(name = 'query1')
from weather#window.lengthBatch(2)#r:eval("c <- sum(time); m <- sum(temp); ", "c long, m double", time, temp) 
select * 
insert into dataOut;

TBD

evalSource (Stream Processor)

R source Stream processor. This extension 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.

Syntax

r:evalSource(<STRING> file.path, <INT|LONG|FLOAT|DOUBLE|STRING|STRING> output.attributes, <INT|LONG|FLOAT|DOUBLE|STRING|STRING> input.attributes)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
file.path The file path of the R script where this script uses the input variable parameters and produces the expected output attributes. STRING No No
output.attributes A set of output attributes separated by commas as string. Each attribute is denoted as <name><space><type>. e.g., 'output1 string, output2 long' INT
LONG
FLOAT
DOUBLE
STRING
STRING
No No
input.attributes A set of input attributes separated by commas after output attributes. e.g., 'att1, att2' INT
LONG
FLOAT
DOUBLE
STRING
STRING
No No
Extra Return Attributes
Name Description Possible Types
outputParameters This runs the R script for each event and produces aggregated outputs based on the provided input variable parameters and expected output attributes. INT
LONG
FLOAT
DOUBLE
STRING
STRING

Examples EXAMPLE 1

@info(name = 'query1')
from weather#window.lengthBatch(2)#r:evalSource("src/test/resources/sample2.R", "m int, c float", time, temp)
select *
insert into dataOut;

This r source function takes in a r script file location and computes the output as defined in the file.