com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Siddhi Extensions

Following are the Siddhi extensions you can use in processing events using WSO2 CEP.

math

Following are the functions of the Math extension.

abs

<double> abs(<float|double> p1)

  • Extension Type: Function

  • Description: Returns the absolute value of p1. This function wraps the java.lang.Math.abs() function.
  • Examples: abs(3)abs(-3)Both these queries return 3, since the absolute value of both 3 and -3 is 3.

acos 

 <double> acos(<float|double> p1)

  • Extension Type: Function
  • Description: Returns the arc-cosine (inverse cosine) of p1 if -1 <= p1 <= 1, or returns NULL otherwise. The return value is in radian scale. This function wraps the java.lang.Math.acos() function.
  • Example: acos(0.5) returns 1.0471975511965979.

asin

<double> asin(<float|double> p1)

  • Extension Type: Function
  • Description: Returns the arc-sin (inverse sine) of p1 if -1 <= p1 <= 1, or returns NULL otherwise. The return value is in radian scale. This function wraps the java.lang.Math.asin() function.
  • Example: asin(0.5) returns 0.5235987755982989.

atan

<double> atan(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Returns the arc-tangent (inverse tangent) of p1. The return value is in radian scale. This function wraps the java.lang.Math.atan() function.
  • Examples: atan(6d) returns 1.4056476493802699.

<double> atan(<int|long|float|double> p1, <int|long|float|double> p2)

  • Extension Type: Function
  • DescriptionReturns the arc-tangent (inverse tangent) of coordinates p1 and p2. The return value is in radian scale. This function wraps the java.lang.Math.atan2() function.
  • Parameterp1: Ordinate coordinate.
  • Parameterp2: Abscissa coordinate.
  • Examplesatan(12d, 5d) returns 1.1760052070951352.

bin

<string> bin(<int|long> p1)

  • Extension Type: Function
  • Description: Returns a string representation of the integer/long argument p1, as an unsigned integer in base 2. This function wraps the java.lang.Integer.toBinaryString and java.lang.Long.toBinaryString methods. 
  • Example: bin(9) returns "1001".

ceil

<double> ceil(<float|double> p1)

  • Extension Type: Function
  • Description: Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument p1, and is equal to a mathematical integer. Wraps java.lang.Math.ceil() method.
  • Example: ceil(423.187d) returns 424.0.

conv

<string> conv(<string> a, <int> fromBase, <int> toBase)

  • Extension Type: Function
  • Description: Converts a from base fromBase to base toBase.
  • Exampleconv("7f", 16, 10) returns "127".

copySign

<double> copySign(<int|long|float|double> magnitude, <int|long|float|double> sign)

  • Extension Type: Function
  • Description: Returns the magnitude of magnitude with the sign of signThis function wraps the java.lang.Math.copySign() function.
  • ExamplecopySign(5.6d, -3.0d) returns -5.6.

cos

<double> cos(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Returns the cosine of p1 (p1 is in radians). This function wraps the java.lang.Math.cos() function.
  • Examplecos(6d) returns 0.9601702866503661.

cosh

<double> cosh(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Returns the hyperbolic cosine of p1 (p1 is in radians). This function wraps the java.lang.Math.cosh() function.
  • Example: cosh(6d) returns 201.7156361224559.

cbrt

<double> cbrt(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Returns the cube-root of p1 (p1 is in radians). This function wraps the java.lang.Math.cbrt() function.
  • Example: cbrt(17d) returns 2.5712815906582356.

e

<double> e()

  • Extension Type: Function
  • Description: Returns the constant java.lang.Math.E, which is the double value that is closer than any other to e, which is the base of the natural logarithms. 
  • Example: e() always return 2.7182818284590452354.

exp

<double> exp(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Returns Euler's number e raised to the power of p1. This function wraps the java.lang.Math.exp() function.
  • Exampleexp(10.23) returns 27722.51006805505.

floor

<double> floor(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: This function wraps the java.lang.Math.floor() function which returns the largest (closest to positive infinity) value that is less than or equal to p1 and is equal to a mathematical integer. 
  • Examplefloor(10.23) returns 10.0.

getExponent

<double> getExponent(<int|long|float|doublep1)

  • Extension Type: Function
  • Description: Returns the unbiased exponent used in the representation of p1. This function wraps the java.lang.Math.getExponent() function.
  • ExamplegetExponent(60984.1) returns 15.

hex

<string> hex(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: This function wraps the java.lang.Double.toHexString() function which returns a hexadecimal string representation of p1.
  • Examplehex(200) returns "c8".

isInfinite

<boolean> isInfinite(<float|double> p1)

  • Extension Type: Function
  • Description: This function wraps the java.lang.Float.isInfinite() and java.lang.Double.isInfinite() functions which returns true, if p1 is infinitely large in magnitude, or returns false otherwise.
  • ExampleisInfinite(java.lang.Double.POSITIVE_INFINITY) returns true.

isNan

<boolean> isNan(<float|double> p1)

  • Extension Type: Function
  • Description: This function wraps the java.lang.Float.isNaN() and java.lang.Double.isNaN() functions which returns true if p1 is a Not-a-Number (NaN) value, or returns false otherwise.
  • ExampleisNan(java.lang.Math.log(-12d)) returns true.

ln

<double> ln(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Returns the natural logarithm (base e) of p1
  • Example: ln(11.453) returns 2.438251704415579.

log2

<double> log2(<int|long|float|double> p1)

  • Extension Type: Function 
  • Description: Returns the base 2 logarithm of p1.
  • Example: log2(91d) returns 6.507794640198696.

log10

<double> log10(<int|long|float|double> p1)

  • Extension Type: Function 
  • Description: Returns the base 10 logarithm of p1.
  • Example: log10(19.234) returns 1.2840696117100832

log

<double> log(<int|long|float|double> number, <int|long|float|double> base)

  • Extension Type: Function
  • Description: Returns the logarithm (base=base) of number.
  • Example: log(34, 2f) returns 5.08746284125034.

max

<double> max(<int|long|float|double> p1<int|long|float|double> p2)

  • Extension Type: Function 
  • Description: Returns the greater of p1 and p2.
  • Example: max(123.67d, 91) returns 123.67.

min

<double> min(<int|long|float|double> p1<int|long|float|double> p2)

  • Extension TypeFunction 
  • Description: Returns the smaller of p1 and p2.
  • Example: min(123.67d, 91) returns 91.

oct

<string> oct(<int|long> p1)

  • Extension TypeFunction 
  • Description: Converts p1 to octal.
  • Example: oct(99l) returns "143".

parseDouble

<double> parseDouble(<string> str)

  • Extension TypeFunction 
  • Description: Returns str as a double.
  • Example: parseDouble("123") returns 123.0.

parseFloat

<float> parseFloat(<string> str)

  • Extension TypeFunction 
  • Description: Returns str as a float.
  • ExampleparseFloat("123") returns 123.0.

parseInt

<int> parseInt(<string> str)

  • Extension TypeFunction 
  • Description: Returns str as an int.
  • ExampleparseInt("123") returns 123.

parseLong

<long> parseLong(<string> str)

  • Extension TypeFunction 
  • Description: Returns str as a long.
  • Example: parseLong("123") returns 123.

pi

<double> pi()

  • Extension Type: Function 
  • Description: Returns the constant java.lang.Math.PI, which is the value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter. 
  • Example: pi() always return 3.141592653589793.

power

<double> power(<int|long|float|double> value<int|long|float|double> toPower)

  • Extension Type: Function 
  • Description: Returns value raised to the power of toPower.
  • Example: power(5.6d, 3.0d) returns 175.61599999999996.

rand

<double> rand()

  • Extension Type: Function 
  • Description: A sequence of calls to rand() generates a stream of pseudo-random numbers. This function internally uses java.util.Random class. 
  • Example: Two sequential calls to rand() may return 0.8263929447650588 and 0.24425883860361197, respectively.

<double> rand(<int|long> seed)

  • Extension TypeFunction 
  • Description: A sequence of calls to rand(seed) generates a stream of pseudo-random numbers. This function internally uses java.util.Random class. 
  • Parameterseed: This is the initial seed given when the random number generation starts. 
  • Example: Two sequential calls to rand(12) may return 0.7298928061101974 and 0.2750691655200749, respectively.

round

<int> round(<float> value)

  • Extension TypeFunction 
  • Description: Returns the closest integer value to the argument
  • Example: round(3.35) will return 3

<long> round(<double> value)

  • Extension TypeFunction 
  • Description: Returns the closest long value to the argument
  • Example: round(3252.353) will return 3252

signum

<int> signum(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Returns the sign of p1 as '1.0' (if a is positive) or '-1.0' (if a is negative), '0.0' otherwise. This function wraps java.lang.Math.signum() function.
  • Example: signum(-6.32d) returns -1.

sin

<double> sin(<int|long|float|double> p1)

  • Extension Type: Function 
  • Description: Returns the sine of p1 (p1 is in radians). This function wraps java.lang.Math.sin() function. 
  • Example: sin(6d) returns -0.27941549819892586.

sinh

<double> sinh(<int|long|float|double> p1)

  • Extension TypeFunction 
  • Description: Returns the hyperbolic sine of p1 (p1 is in radians). This function wraps java.lang.Math.sinh() function. 
  • Example: sinh(6d) returns 201.71315737027922.

sqrt

<double> sqrt(<int|long|float|double> p1)

  • Extension Type: Function
  • DescriptionReturns the square-root of p1. This function wraps java.lang.Math.sqrt() function. 
  • Example: sqrt(4d) returns 2.

tan

<double> tan(<int|long|float|double> p1)

  • Extension TypeFunction 
  • Description: Returns the tan of p1 (p1 is in radians). This function wraps java.lang.Math.tan() function. 
  • Example: tan(6d) returns -0.29100619138474915.

tanh

<double> tanh(<int|long|float|double> p1)

  • Extension TypeFunction 
  • Description: Returns the hyperbolic tangent of p1 (p1 is in radians). This function wraps java.lang.Math.tanh() function. 
  • Example: tanh(6d) returns 0.9999877116507956.

toDegrees

<double> toDegrees(<int|long|float|double> p1)

  • Extension Type: Function
  • Description: Converts p1 from radians to degrees. This function wraps java.lang.Math.toDegrees() function.
  • Example: toDegrees(6d) returns 343.77467707849394.

toRadians

<double> toRadians(<int|long|float|double> p1)

  • Extension TypeFunction
  • Description: Converts p1 from degrees to radians. This function wraps java.lang.Math.toRadians() function.
  • Example: toRadians(6d) returns 0.10471975511965977.

str

Following are the functions of the String extension.

charAt

<string> charAt(<string> str, <int> index)

  • Extension Type: Function

  • Description: Returns the char value in str at the specified index.
  • Examples: charAt("WSO2", 1) returns 'S'

coalesce

<int|long|float|double|string|boolean> coalesce(<int|long|float|double|string|boolean> arg1, <int|long|float|double|string|boolean> arg2,.., <int|long|float|double|string|boolean> argN)

  • Extension Type: Function 
  • Description: Returns the value of the first of its input parameters that is not null.
  • Parameters: This function accepts any number of parameters and they can be of different types too.
  • Return Type: Return type will be the type of the first of its input parameters that is not null.
  • Examplescoalesce("123", null, "789") returns "123". coalesce(null, "BBB", "CCC") returns "BBB". coalesce(null, null, null) returns null. 

concat

<string> concat (<int|long|float|double|string|boolean> arg1<int|long|float|double|string|boolean> arg2,.., <int|long|float|double|string|boolean> argN)

  • Extension Type: Function 
  • Description: Returns a string that is the result of concatenating the given arguments: arg1, arg2, .., argN.
  • Examples: concat("D533", "8JU^", "XYZ") returns "D5338JU^XYZ". concat("AAA", null, "CCC") returns "AAACCC".

hex

<string> hex (<string> str)

  • Extension Type: Function 
  • Description: Returns a hexadecimal string representation of str
  • Example: hex("MySQL") returns "4d7953514c".

length

<int> length (<string> str)

  • Extension Type: Function 
  • Description: Returns the length of the string: str.
  • Example: length("Hello World") returns 11.

lower

<string> lower (<string> str)

  • Extension Type: Function 
  • Description: Converts the capital letters in the input string: str, to the equivalent simple letters.
  • Example: lower("WSO2 cep ") returns "wso2 cep ".

regexp

<boolean> regexp (<string> str, <string> regex)

  • Extension Type: Function 
  • Description: Tells whether or not the string: str, matches the given regular expression: regex.
  • Example: regexp("WSO2 abcdh", "WSO(.*h)") returns true. 

repeat

<string> repeat (<string> str, <int> times)

  • Extension Type: Function
  • Description: Repeats the string: str, for a specified number of times: times.
  • Example: repeat("StRing 1", 3) returns "StRing 1StRing 1StRing 1".

replaceAll

<string> replaceAll (<string> str, <string> regex<string> replacement)

  • Extension Type: Function 
  • Description: Replaces each substring of str that matches the given regex with the given replacement.
  • Example: replaceAll("hello hi hello",  'hello', 'test') returns "test hi test".

replaceFirst

<string> replaceFirst(<string> str<string> regex<string> replacement)

  • Extension Type: Function 
  • Description: Replaces the first substring of str that matches the given regex with the given replacement.
  • Example: replaceFirst("hello WSO2 A hello",  'WSO2(.*)A', 'XXXX') returns "hello XXXX hello"

reverse

<string> reverse (<string> str)

  • Extension Type: Function 
  • Description: Returns the reverse ordered string of str.
  • Example: reverse("Hello World") returns "dlroW olleH".

strcmp

<int> strcmp (<string> str, <string> compareTo)

  • Extension Type: Function
  • Description: Compares str with compareTo strings lexicographically.
  • Examples: strcmp("Hello", 'Hello') returns 0. strcmp("AbCDefghiJ KLMN", 'Hello') returns -7.

substr

<string> substr (<string> sourceText, <int> beginIndex)

  • Extension Type: Function
  • Description: Returns a new string that is a substring of sourceText.
  • Example: substr("AbCDefghiJ KLMN", 4) returns "efghiJ KLMN".

<string> substr (<string> sourceText<int> beginIndex<int> length)

  • Extension TypeFunction 
  • Description: Returns a new string that is a substring of sourceText.
  • Examplesubstr("AbCDefghiJ KLMN",  2, 4) returns "CDef".

<string> substr (<string> sourceText, <string> regex)

  • Extension TypeFunction
  • Description: Returns a new string that is a substring of sourceText.  
  • Examples: substr("WSO2D efghiJ KLMN", '^WSO2(.*)') returns "WSO2D efghiJ KLMN". 

<string> substr (<string> sourceText, <string> regex<int> groupNumber)

  • Extension TypeFunction 
  • Description: Returns a new string that is a substring of sourceText.
  • Example: substr("WSO2 cep WSO2 XX E hi hA WSO2 heAllo",  'WSO2(.*)A(.*)',  2) returns " ello".

trim

<string> trim (<string> str)

  • Extension Type: Function
  • Description: Returns a copy of str, with leading and trailing white-spaces omitted.
  • Example: trim("  AbCDefghiJ KLMN  ") returns "AbCDefghiJ KLMN".

unhex

<string> unhex (<string> str)

  • Extension Type: Function
  • Description: This is the equivalent of 'unhex' function in mysql 5.0. unhex(str) interprets each pair of characters in str as a hexadecimal number. Also see hex() string-extension in Siddhi.
  • Example: unhex("4d7953514c") returns "MySQL".

upper

<string> upper(<string> str)

  • Extension Type: Function
  • Description: Converts the simple letters in the input string: str to the equivalent capital letters. 
  • Example: upper("Hello World") returns "HELLO WORLD"

contains

<bool> contains(<string> inputSequence<string> searchingSequence)

  • Extension TypeFunction
  • Description: method returns true if and only if the inputSequence contains the specified sequence of char values in the searchingSequence
  • Examplecontains("21 products are produced by WSO2 currently", "WSO2") returns true

geo

Following are the functions of the Geo extension.

intersects

<bool> intersects(<string> geoJSONGeometry , <string> geoJSONGeometryFence)

  • Extension TypeFunction
  • Description: Returns true if the incoming event geoJSONGeometry intersects the given geoJSONGeometryFence else false.
  • Example: intersects( {'type':'Polygon','coordinates':[[[0.5, 0.5],[0.5, 1.5],[1.5, 1.5],[1.5, 0.5],[0.5, 0.5]]]} , {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]} ), returns true because geoJSONGeometry intersects geoJSONGeometryFence.

<bool> intersects(<double> longitude , <double> latitude , <string> geoJSONGeometryFence)

  • Extension TypeFunction
  • Description: Returns true if the location pointed by longitude and latitude intersects the given geoJSONGeometryFence else false.
  • Example: intersects(0.5. 0.5 , {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]}), returns true because location pointed by longitude and latitude intersects geoJSONGeometryFence .

within

<bool> within(<double> longitude , <double> latitude, <string> geoJSONGeometryFence)

  • Extension TypeFunction
  • Description: Returns true if the location pointed by longitude and latitude is within the geoJSONGeometryFence else false.
  • Examples: within(0.5, 0.5, {'type':'Polygon','coordinates':[[[0,0],[0,2],[1,2],[1,0],[0,0]]]} ) returns true while within(2, 2, {'type':'Polygon','coordinates':[[[0,0],[0,2],[1,2],[1,0],[0,0]]]} ) returns false.

<bool> within(<string> geoJSONGeometry , <string> geoJSONGeometryFence )

  • Extension TypeFunction
  • Description: Returns true if geoJSONGeometry is within the geoJSONGeometryFence else false.
  • Examples: within( {'type': 'Circle', 'radius': 110575, 'coordinates':[1.5, 1.5]} , {'type':'Polygon','coordinates':[[[0,0],[0,4],[3,4],[3,0],[0,0]]]} ) returns true while,
     within( {'type': 'Circle', 'radius': 110575, 'coordinates':[0.5, 1.5]} , {'type':'Polygon','coordinates':[[[0,0],[0,4],[3,4],[3,0],[0,0]]]} ) returns false.

withindistance

<bool> withindistance(<double> longitude , <double> latitude, <string> geoJSONGeometryFence)

  • Extension TypeFunction
  • Description: Returns true if the location given by longitude and latitude is within distance of the geoJSONGeometryFence else false.
  • Example: withindistance( 0.5 , 0.5, {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]}, 110574.61087757687) returns true because location given by longitude and latitude is within distance of geoJSONGeometryFence.

<bool> withindistance(<string> geoJSONGeometry , <string> geoJSONGeometryFence , <double> distance)

  • Extension TypeFunction 
  • Description: Returns true if the area given by geoJSONGeometry is within distance of the geoJSONGeometryFence else false.
  • Example: withindistance( {'type':'Polygon','coordinates':[[[0.5, 0.5],[0.5, 1.5],[1.5, 1.5],[1.5, 0.5],[0.5, 0.5]]]} , {'type':'Polygon','coordinates':[[[0, 0],[0, 1],[1, 1],[1, 0],[0, 0]]]}, 110574.61087757687) returns true because geoJSONGeometry is within distance of geoJSONGeometryFence.

crosses

<bool> crosses(<string> id , <double> longitude, <double> latitude , <string> geoJSONGeometryFence)

  • Extension Type: StreamProcessor
  • Description:  An event with 'crosses' additional attribute set to true when the object ((longitude, latitude)) crosses into geoJSONGeometryFence and an event with `crosses` additional attribute set to false when the object crosses out of the geoJSONGeometryFence.
  • Example: crosses(km-4354, -0.5, 0.5, {'type':'Polygon','coordinates':[[[0, 0],[2, 0],[2, 1],[0, 1],[0, 0]]]} ) and crosses(km-4354, 1.5, 0.5, {'type':'Polygon','coordinates':[[[0, 0],[2, 0],[2, 1],[0, 1],[0, 0]]]} ) return true because these geo locations crosses each other.

<bool> crosses(<string> id , <string> geoJSONGeometry , <string> geoJSONGeometryFence)

  • Extension Type: StreamProcessor
  • Description:  An event with 'crosses' additional attribute set to true when the object (geoJSONGeometry) crosses into geoJSONGeometryFence and an event with `crosses` additional attribute set to false when the object crosses out of the geoJSONGeometryFence.
  • Example

stationary

<bool> stationary(<string> id , <double> longitude, <double> latitude , <string> geoJSONGeometryFence , <double> radius)

  • Extension Type: StreamProcessor
  • Description:  When the object (longitude, latitude) starts being stationary within the radius an event with 'stationary' additional attribute set to true. When the object starts to move out of the radius an event with 'stationary' additional attribute set to false.
  • Example: stationary(km-4354,0,0, 110574.61087757687) and stationary(km-4354,1,1, 110574.61087757687) and stationary(km-4354,1,1.5, 110574.61087757687) return true.

<bool> stationary(<string> id , <string> geoJSONGeometry , <string> geoJSONGeometryFence, <double> radius)

  • Extension Type: StreamProcessor
  • Description: When the object (geoJSONGeometry) starts being stationary within the radius an event with 'stationary' additional attribute set to true. When the object starts to move out of the radius an event with 'stationary' additional attribute set to false.
  • Example

proximity

<bool,string> proximity(<string> id , <double> longitude, <double> latitude , <string> geoJSONGeometryFence , <double> radius)

  • Extension Type: StreamProcessor
  • Description:  When two objects (longitude, latitude) starts being in close proximity within the radius an event with 'inCloseProximity' additional attribute set to true. When the object starts to move out of the radius an event with 'inCloseProximity' additional. attribute set to false. On each event, additional attributes 'proximityWith' gives the id of the object that this object is in close proximity and 'proximityId' is an id unique to the pair of objects.
  • Example: proximity(1, 0, 0, 110574.61087757687) and proximity(2, 1, 1, 110574.61087757687) and proximity(3, 2, 2, 110574.61087757687) and proximity(1, 1.5, 1.5, 110574.61087757687) returns true with ID 3.

<bool> proximity(<string> id , <string> geoJSONGeometry , <string> geoJSONGeometryFence, <double> radius)

  • Extension Type: StreamProcessor
  • Description: When two objects (geoJSONGeometry) starts being in close proximity within the radius an event with 'inCloseProximity' additional attribute set to true. When the object starts to move out of the radius an event with 'inCloseProximity' additional. attribute set to false. On each event, additional attributes 'proximityWith' gives the id of the object that this object is in close proximity and 'proximityId' is an id unique to the pair of objects.
  • Example

geocode

<double, double, string> geocode(<string> location)

  • Extension Type: StreamProcessor
  • Description:  transforms a location into its geo-coordinates ( longitude and latitude ) and formatted address
  • Example: geocode(duplication rd) returns  the following data 6.8995244d, 79.8556202d, "R A De Mel Mawatha, Colombo, Sri Lanka" with adhering latitude, longitude, formattedAddress attribute names respectively.

r

Following are the functions of the R extension.

eval

[<int|long|float|double|string|booleanoutput1<int|long|float|double|string|boolean> output2, ...] eval (<stringscript, <string> outputAttributes,<int|long|float|double|string|booleaninput1<int|long|float|double|string|booleaninput2, ...)
  • Extension Type Stream Processor 
  • Description: This will run the R script for each event and produce aggregated outputs based on the provided input variable parameters and expected output attributes. 
  • Parameterscript: R script as a string that uses the input variable parameters and produce the expected output attributes.
  • ParameteroutputAttributes: All output attributes separated by comma as string here each attribute is denoted as <name><space><type>. e.g., 'output1 string, output2 long'
  • Parameterinput1, input2, ...: Input parameters have to be variable attributes of the input stream, function does not accept any constant values as input parameters. 
  • Return Parameter: output1, output2, ...: Output parameters will be generated according to the provided outputAttributes.

  • Examples: eval('totalItems <- sum(items); totalTemp <- sum(temp);', 'totalItems int, totalTemp double', items, temp) where items being int and temp being double will return [ totalItems, totalTemp ] where totalTemp will be int and totalTemp will be double.

evalSource

[<int|long|float|double|string|booleanoutput1<int|long|float|double|string|boolean> output2, ...] eval (<stringfilePath, <string> outputAttributes,<int|long|float|double|string|booleaninput1<int|long|float|double|string|boolean> input2, ...)
  • Extension Type Stream Processor 
  • Description: This will run the R script loaded from a file for each event and produce aggregated outputs based on the provided input variable parameters and expected output attributes. 
  • ParameterfilePath: The file path of R script where this script that uses the input variable parameters and produce the expected output attributes. 
  • ParameteroutputAttributes: All output attributes separated by comma as string here each attribute is denoted as <name><space><type>. e.g., 'output1 string, output2 long'
  • Parameterinput1, input2, ...: Input parameters have to be variable attributes of the input stream, function does not accept any constant values as input parameters. 
  • Return Parameter: output1, output2, ...: Output parameters will be generated according to the provided outputAttributes.

  • Examples: eval('/home/user/test/script1.R', 'totalItems int, totalTemp double', items, temp) where items being int and temp being double will return [ totalItems, totalTemp ] where totalTemp will be int and totalTemp will be double.

regex

Following are the functions of the RegEx extension.

find

<bool> find(<string> regex , <stringinputSequence)

  • Extension TypeFunction
  • Description: This method attempts to find the next sub-sequence of the 'inputSequence' that matches the 'regex' pattern and returns true if the sub sequence exists else false
  • Examples: find("\d\d(.*)WSO2", "21 products are produced by WSO2 currently") returns true while find("\d\d(.*)WSO2", "21 products are produced currently") returns false.

<bool> find(<stringregex , <stringinputSequence, <int> startingIndex)

  • Extension TypeFunction
  • Description: This method attempts to find the next sub-sequence of the 'inputSequence' that matches the 'regex' pattern starting from a given index in the 'inputSequence' and returns true if the sub sequence exists else false
  • Examples: find("\d\d(.*)WSO2", "21 products are produced within 10 years by WSO2 currently by WSO2 employees",  30) returns true while find("\d\d(.*)WSO2", "21 products are produced within 10 years by WSO2 currently by WSO2 employees", 35) returns false.

group

<string> group(<string> regex , <stringinputSequence <int> groupId)

  • Extension TypeFunction
  • Description: This method returns the input sub-sequence captured by the given group during the previous match operation else returns null
  • Examples: group("(\d\d)(.*)(WSO2.*)", "21 products are produced within 10 years by WSO2 currently by WSO2 employees", 3) returns "WSO2 employees".

lookingAt

<string> lookingAt(<string> regex , <string> inputSequence)

  • Extension TypeFunction
  • Description: This method attempts to match the 'inputSequence', starting at the beginning, against the 'regex' pattern.
  • Examples: lookingAt("\d\d(.*)WSO2", "21 products are produced by WSO2 currently in Sri Lanka") returns true while lookingAt("WSO2(.*)middleware(.*)", "sample test string and WSO2 is situated in trace and its a middleware company") returns false.

matches

<string> matches(<string> regex , <string> inputSequence)

  • Extension TypeFunction
  • Description: This method attempts to match the entire 'inputSequence' against the 'regex' pattern.
  • Examples: matches("WSO2(.*)middleware(.*)", "WSO2 is situated in trace and its a middleware company") returns true while matches("WSO2(.*)middleware", "WSO2 is situated in trace and its a middleware company") returns false.

time

Following are the functions of the time extension.

currentDate

<string> currentDate()

  • Extension TypeFunction
  • Description: This method returns current system date in yyyy-MM-dd format.
  • Examples: currentDate() returns 2015-08-20.

currentTime

<string> currentTime()

  • Extension TypeFunction
  • Description: This method returns current system time in HH:mm:ss format.
  • Examples: currentTime() returns 13:15:10.

currentTimestamp

<string> currentTimestamp()

  • Extension TypeFunction
  • Description: This method returns current system timestamp in yyyy-MM-dd HH:mm:ss format.
  • Examples: currentTime() returns 2015-08-20 13:15:10.

dateAdd

  • dateValue - value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657"
  • expr - In which amount, selected date format part should be incremented. eg: 2 ,5 ,10 etc
  • unit - Which part of the date format you want to manipulate. eg: "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" , * "WEEK" , "DAY" , "SECOND"
  • dateFormat - Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS
  • timestampInMilliseconds - date value in milliseconds.(from the epoch) eg: 1415712224000L

<string> dateAdd(<string> dateValue , <longexpr, <string> unit, <string> dateFormat)

  • Extension TypeFunction
  • Description: this method returns added specified time interval to a date.
  • Examples: dateAdd("2014-11-11 13:23:44", 2, 'year',"yyyy-MM-dd HH:mm:ss") will return "2016-11-11 13:23:44"

<string> dateAdd(<string> dateValue , <longexpr, <string> unit)

  • Extension TypeFunction
  • Description: this method returns added specified time interval to a date.
  • Examples: dateAdd("2014-11-11 13:23:44", 2, 'year') will return "2016-11-11 13:23:44"

<stringdateAdd(<long> timestampInMilliseconds, <long> expr, <string> unit)

  • Extension TypeFunction
  • Description: this method returns added specified time interval to a timestamp in milliseconds.
  • Examples: dateAdd(1415692424000L, 2, 'year') will return "2016-11-11 13:23:44"

dateSub

  • dateValue - value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657" 
  • unit - Which part of the date format you want to manipulate. eg: "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" , * "WEEK" , "DAY" , "SECOND" 
  • expr - In which amount, selected date format part should be decremented. eg: 2 ,5 ,10 etc 
  • dateFormat - Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS 
  • timestampInMilliseconds - date value in milliseconds.(from the epoch) eg: 1415712224000L

<string> dateSub(<string> dateValue , <long> expr, <string> unit, <string> dateFormat)

  • Extension TypeFunction
  • Description: this method returns added specified time interval to a date.
  • Examples: dateSub("2014-11-11 13:23:44", 2, 'year',"yyyy-MM-dd HH:mm:ss") will return "2012-11-11 13:23:44"

<string> dateSub(<string> dateValue , <longexpr, <string> unit)

  • Extension TypeFunction
  • Description: this method returns added specified time interval to a date.
  • Examples: dateSub("2014-11-11 13:23:44", 2, 'year') will return "2012-11-11 13:23:44"

<string> dateSub(<long> timestampInMilliseconds, <long> expr, <string> unit)

  • Extension TypeFunction
  • Description: this method returns added specified time interval to a timestamp in milliseconds.
  • Examples: dateSub(1415692424000L, 2, 'year') will return 1352620424000

dateDiff

  • dateValue1 - value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657" 
  • dateValue2 - value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657" 
  • dateFormat1 - Date format of the provided dateValue1. eg: yyyy-MM-dd HH:mm:ss.SSS
  • dateFormat2 - Date format of the provided dateValue2. eg: yyyy-MM-dd HH:mm:ss.SSS
  • timestampInMilliseconds1 - date value in milliseconds.(from the epoch) eg: 1415712224000L 
  • timestampInMilliseconds2 - date value in milliseconds.(from the epoch) eg: 1423456224000L

<int> dateDiff(<string> dateValue1, <string> dateValue2<string> dateFormat1, <string> dateFormat2)

  • Extension TypeFunction
  • Description: Returns time(days) between two dates.
  • Examples: dateDiff('2014-11-11 13:23:44', '2014-11-9 13:23:44', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm:ss') will return 2

<int> dateDiff(<string> dateValue1, <string> dateValue2)

  • Extension TypeFunction
  • Description: Returns time(days) between two dates.
  • Examples: dateDiff('2014-11-11 13:23:44.000', '2014-11-9 13:23:44.000') will return 2

<int> dateDiff(<string> timestampInMilliseconds1, <string> timestampInMilliseconds2)

  • Extension TypeFunction
  • Description: Returns time(days) between two dates.
  • Examples: dateDiff(1415692424000, 1415519624000) will return 2

dateFormat

  • dateValue - value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657" 
  • dateTargetFormat - Date format which need to be converted to. eg: yyyy/MM/dd HH:mm:ss 
  • dateSourceFormat - Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS
  • timestampInMilliseconds - date value in milliseconds.(from the epoch) eg: 1415712224000L 
  • dateTargetFormat - Date format which need to be converted to. eg: yyyy/MM/dd HH:mm:ss

<string> dateFormat(<string> dateValue,<string> dateTargetFormat,<string> dateSourceFormat)

  • Extension TypeFunction
  • Description: Returns a formatted date string
  • Examples: dateFormat('2014-11-11 13:23:55', 'ss', 'yyyy-MM-dd HH:mm:ss') will return 55

<string> dateFormat(<string> dateValue,<string> dateTargetFormat)

  • Extension TypeFunction
  • Description: Returns a formatted date string
  • Examples: dateFormat('2014-11-11 13:23:55.657', 'ss') will return 55

<string> dateFormat(<long> timestampInMilliseconds,<string> dateTargetFormat)

  • Extension TypeFunction
  • Description: Returns a formatted date string
  • Examples: dateFormat(1415692424000, 'yyyy-MM-dd') will return 2014-11-11  

extract

  • dateValue - value of date. eg: "2014-11-11 13:23:44.657", "2014-11-11" , "13:23:44.657" 
  • unit - Which part of the date format you want to manipulate. eg: "MINUTE" , "HOUR" , "MONTH" , "YEAR" , "QUARTER" , * "WEEK" , "DAY" , "SECOND" 
  • dateFormat - Date format of the provided date value. eg: yyyy-MM-dd HH:mm:ss.SSS 
  • timestampInMilliseconds - date value in milliseconds.(from the epoch) eg: 1415712224000L

<int> extract(<string> unit,<string> dateValue, <string> dataFormat)

  • Extension TypeFunction
  • Description: This method returns the time component of the dateValue specified in unit parameter
  • Examples: extract('year', '2014-3-11 02:23:44', 'yyyy-MM-dd hh:mm:ss') will return 2014

<int> extract(<string> unit,<string> dateValue)

  • Extension TypeFunction
  • Description: This method returns the time component of the dateValue specified in unit parameter
  • Examples: extract('year', '2014-3-11 02:23:44.234') will return 2014

<int> extract(<long> timestampInMilliseconds,<string> unit)

  • Extension TypeFunction
  • Description: This method returns the time component of the dateValue specified in unit parameter
  • Examples: extract(1394484824000, 'year') will return 2014

date

<string> date(<string> dateValue,<string> dateFormat)

  • Extension TypeFunction
  • Description: This method returns the date component of the dateValue
  • Examples: extact('2014-11-11 13:23:44', 'yyyy-MM-dd HH:mm:ss') will return 2014-11-11

timestampInMilliseconds

<long> timestampInMilliseconds()

  • Extension TypeFunction
  • Description: This method returns the current timestamp in milliseconds
  • Examples: timestampInMilliseconds() will return 1440160328693

<long> timestampInMilliseconds(<string> dateValue)

  • Extension TypeFunction
  • Description: This method returns the timestamp of the value specified in dateValue parameter. The value should be in 'yyyy-MM-dd HH:mm:ss.SSS' format
  • Examples: timestampInMilliseconds('2007-11-30 10:30:19.000') will return 1196398819000

<long> timestampInMilliseconds(<string> dateValue, <string> dateFormat)

  • Extension TypeFunction
  • Description: This method returns the timestamp of the value specified in dateValue parameter. The date format can be given in the dateFormat parameter
  • Examples: timestampInMilliseconds('2007-11-30 10:30:19', 'yyyy-MM-dd HH:mm:ss') will return 1196398819000

utcTimestamp

<string> utcTimestamp()

  • Extension TypeFunction
  • Description: Returns System time in yyyy-MM-dd HH:mm:ss format.
  • Examples: utcTimestamp() will return 2015-08-21 12:16:13


nlp

findNameEntityType

<string> findNameEntityType(<string> entityType, <bool> groupSuccessiveMatch, <string> string-variable)

  • Extension TypeFunction
  • Description
    • The findNameEntityType function takes in 
      • entityType: a user given string constant as entity Type - PERSON, LOCATION, ORGANIZATION, MONEY, PERCENT, DATE or TIME
      • groupSuccessiveMatchuser given boolean constant in order to group successive matches of the given entity type and a text stream. 
      • streamAttribute: a string or the stream attribute which the text stream resides
    • It returns the entities in the text. If we give group successive matches as true the result will aggregate successive words of the same entity type.
  • Examples: findNameEntityType("PERSON",true,text), if text attribute contains "Bill Gates donates £31million to fight Ebola" result will be "Bill Gates". If groupSuccessiveMatch is "false" two events will be generated as "Bill" and "Gates".

findNameEntityTypeViaDictionary

<string> findNameEntityTypeViaDictionary(<string> entityType, <string> dictionaryFilePath<string> string-variable)

  • Extension TypeFunction
  • Description
    • The findNameEntityType function takes in 
      • entityType: a user given string constant as entity Type - PERSON, LOCATION, ORGANIZATION, MONEY, PERCENT, DATE or TIME
      • dictionaryFilePathpath to the dictionary which expected entities for the entity types and the dictionary should be in the following form
      • string-variable: a string or the stream attribute which the text stream resides
    • It returns the entities in the text. If we give group successive matches as true the result will aggregate successive words of the same entity type.
  • Examples: findNameEntityTypeViaDictionary("PERSON","dictionary.xml",text): If the text attribute contains "Bill Gates donates £31million to fight Ebola", and the dictionary consists of the above entries , the result will be "Bill".

findRelationshipByVerb

<stringtext, <string> subject<string> object <string> verb findRelationshipByVerb(<string> verb, <string> string-variable)

  • Extension TypeFunction
  • Descriptiontakes in a user given string constant as a verb, and a text stream. Then it returns whole text,  subject, object, verb relationship from the text stream that can be extracted for any form of that verb
    • The findRelationshipByVerb function takes in 
      • verb: user given string constant
      • string-variable: a string or the stream attribute which the text stream resides
    • It returns the complete string, subject object and the verb if the entered verb is resides in the input text.
  • Examples: findRelationshipByVerb("say", "Information just reaching us says another Liberian With Ebola Arrested At Lagos Airport"), returns 4 parameters. the whole text, subject as Information, object as Liberian, verb as "says".

findRelationshipByRegex

<stringtext, <string> subject<string> object <string> verb findRelationshipByRegex(<string> regex, <string> string-variable)

  • Extension TypeFunction
  • Descriptionit returns whole text, subject, object and verb from the text stream that match with the named nodes of the Semgrex pattern
    • The findRelationshipByRegex function takes in 
      • regex: user given regular expression that match the Semgrex pattern syntax
      • string-variable: a string or the stream attribute which the text stream resides
    • It returns the entities in the text. If we give group successive matches as true the result will aggregate successive words of the same entity type.
  • Examples: findRelationshipByRegex('{}=verb >/nsubj|agent/ {}=subject >/dobj/ {}=object', "gates foundation donates $50M in support of #Ebola relief"), returns 4 parameters. the whole text, subject as "foundation", object as "$", verb as "donates".

findSemgrexPattern

<stringtext, <string> match<string> object <string> verb findSemgrexPattern(<string> regex, <string> string-variable)

  • Extension TypeFunction
  • Descriptionit returns whole text, subject, object and verb from the text stream that match with the named nodes of the Semgrex pattern
    • The findSemgrexPattern function takes in 
      • regex: user given regular expression that match the Semgrex pattern syntax
      • string-variable: a string or the stream attribute which the text stream resides
    • it returns word(s)/phrase(s) from the text stream that match with the Semgrex pattern and word(s)/relation(s) that match with each named node and each named relation defined in the regular expression.
  • Examples: findSemgrexPattern('{lemma:die} >/.*subj|num.*/=reln {}=diedsubject', "Sierra Leone doctor dies of Ebola after failed evacuation.") returns 4 parameters. the whole text, match as "dies", reln as "nsubj", diedsubject as "doctor".
    • This will look for words with lemmatization die which are governors on any subject or numeric relation. The dependent is marked as the diedsubject and the relationship is marked as reln. Thus, the query will return an output stream that will out the full match of this expression, i.e the governing word with lemmatization for die. In addition it will out the named node diedsubject and the named relation reln for each match it find.

findTokensRegexPattern

<string> text, <string> match, <string> group_1, etc. findTokensRegexPattern(<string> regex, <string> string-variable)

  • Extension TypeFunction
  • Descriptionit returns whole text, subject, object and verb from the text stream that match with the named nodes of the Semgrex pattern
    • The findTokensRegexPattern function takes in 
      • regex: user given regular expression that match the Semgrex pattern syntax
      • string-variable: a string or the stream attribute which the text stream resides
    • it returns word(s)/phrase(s) from the text stream that match with the Semgrex pattern and word(s)/relation(s) that match with each named node and each named relation defined in the regular expression.
  • Examples: findTokensRegexPattern('([ner:/PERSON|ORGANIZATION|LOCATION/]+) (?:[]* [lemma:donate]) ([ner:MONEY]+)', text) returns 4 parameters. the whole text, match as "Paul Allen donates $ 9million", group_1 as "Paul Allen", group_2 as "$ 9million".
    • It defines three groups and the middle group is defined as a non capturing group. The first group looks for words that are entities of either PERSON, ORGANIZATON or LOCATION with one or more successive words matching same. Second group represents any number of words followed by a word with lemmatization for donate such as donates, donated, donating etc. Third looks for one or more successive entities of type MONEY.

pmml 

predict

<double|float|long|int|string|booleanpredict(<string> pathToPmmlFile)

  • Extension TypeStream Processor 
  • Description: Process the input stream attributes according to the defined PMML standard model and outputs the processed results along with the input stream attributes.
    • The predict function takes in 
      • pathToPmmlFile: path to the PMML model file
    • Returns the outputs defined in the output fields. The number of outputs can be varied.
  • Examplespredict('<CEP HOME>/samples/artifacts/0301/decision-tree.pmml')
    • This model is implemented to detect network intruders. The input event stream is processed by the execution plan which uses the pmml predictive model to detect whether a particular user is an intruder to the network or not. The output stream contains the processed query results which includes the predicted responses along with the feature values extracted from the input event stream.

 <double|float|long|int|string|booleanpredict(<string> pathToPmmlFile,  <double|float|long|int|string|boolean> input)

  • Extension TypeStream Processor 
  • Description: Process the input stream attributes according to the defined PMML standard model and outputs the processed results.
    • The predict function takes in
      • pathToPmmlFile: path to the PMML model file
      • input: attribute of the input stream which is sent to the PMML model as values for predictions. Function does not accept any constant values as input parameters. You can have multiple input parameters according to the input stream definition.
    • Returns the processed outputs defined in the query. The number of outputs can be varied according to the query definition.
  • Examplespredict('<CEP HOME>/samples/artifacts/0301/decision-tree.pmml', root_shell, su_attempted, num_root, num_file_creations, num_shells, num_access_files, num_outbound_cmds, is_host_login, is_guest_login , count, srv_count, serror_rate, srv_serror_rate)
    • This model is implemented to detect network intruders. The input event stream is processed by the execution plan which uses the pmml predictive model to detect whether a particular user is an intruder to the network or not. The output stream contains the processed query results which includes the predicted responses.

ml

predict

<double|float|long|int|string|boolean> predict(<string> pathToMLModel, <string> dataType)

  • Extension TypeStreamProcessor
  • Description: Returns an output event with the additional attribute with the response variable name of the model, set with the predicted value, using the feature values extracted from the input event.
    • The predict function takes in
      • pathToMLModel:  The file path or the registry path where ML model is located. If the model storage location is registry, the value of this this parameter should have the prefix “registry:”
      • dataType: Data type of the predicted value (double, float, long, integer/int, string, boolean/bool). 
  • Examplepredict(‘registry:/_system/governance/mlmodels/indian-diabetes-model’)

<double|float|long|int|string|boolean> predict(<string> pathToMLModel, <string> dataType, <double> input)

  • Extension TypeStreamProcessor
  • Description: Returns an output event with the additional attribute with the response variable name of the model, set with the predicted value, using the feature values extracted from the input event.
    • The predict function takes in
      • pathToMLModel: The file path or the registry path where ML model is located. If the model storage location is registry, the value of this parameter should have the prefix registry:
      • dataType: Data type of the predicted value (double, float, long, integer/int, string, boolean/bool).

      • input: A variable attribute value of the input stream which is sent to the ML model as feature values for predictions. Function does not accept any constant values as input parameters. You can have multiple input parameters.  

  • Examplepredict(‘registry:/_system/governance/mlmodels/indian-diabetes-model’, NumPregnancies, TSFT, DPF, BMI, DBP, PG2, Age, SI2)

timeseries

Refer Time Series Extension

 

kf (Kalman Filter)

Following are the functions of the Kalman Filter extension.

kalmanFilter

  • Description:  Uses measurements observed over time, containing noise and other inaccuracies, and produces estimated values for the current measurement.

<double, double> kalmanFilter(<double> measuredValue)

  • Extension TypeFunction
  • Example

<double, double> kalmanFilter(<double> measuredValue, <double> measurementNoiseSD)

  • Extension TypeFunction
  • Example
    • 1st round - kf:kalmanFilter(-74.178444) will result with estimated value which is -74.178444.
    • 2nd round - kf:kalmanFilter(-74.177872) will result with estimated value which is -74.17815800142999.
    • 3rd round - kf:kalmanFilter(-74.175703) will result with estimated value which is -74.17733967034776.

<double, double> kalmanFilter(<double> measuredValue,  <double> measuredChangingRate, <double> measurementNoiseSD, <long> timestamp)

  • Extension TypeFunction
  • Example
    • 1st round - kf:kalmanFilter(-74.178444) will result with estimated value which is -74.1784439700006.
    • 2nd round - kf:kalmanFilter(-74.177872) will result with estimated value which is -74.17657538193608.
    • 3rd round - kf:kalmanFilter(-74.175703) will result with estimated value which is -74.17487924016262.

smooth

<double> smooth(<double> latitude)

  • Extension Type: Function Extension
  • Description:  Uses to reduce the noise in the event attribute.
  • Example: kf:smooth(40.695881) will result with estimated values which are 40.696

 

 

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.