Monday 15 March 2010

WSO2 CEP custom function doesn't work as aggregate function -



WSO2 CEP custom function doesn't work as aggregate function -

wso2 cep custom function doesn't work aggregate function, instead operates on each row of data.

lets have value1 , value2 in input stream.

host:a, value1:1, value2:10 host:a, value1:2, value2:20 host:a, value1:3, value2:30 host:a, value1:4, value2:40 host:a, value1:5, value2:50

now have done time batching , grouping host. , have written custom function finds median, , used inbuilt function sum.

but is, applies sum functions on 5 rows after grouping custom function invoked row row. process method in custom function class getting called row row. hence sum returns 15 median function gives output 50 lastly value2.

execution plan query

from inputstream#window.timebatch(10 sec) select value1 value1, value2 value2, sum(value1) sumofvalue1, custom:median(value2) medianofvalue2 grouping host insert outputstream;

custom function java class snippet

/** * method called when sending events process * * @param obj * @return */ @override protected object process(object obj) {

can't have custom aggregate function, or if custom function supposed executed on row row basis ???

you can solve writing custom outputattributeaggregator instead of custom function. outputattributeaggregator supposed used such scenarios , functions individual rows.

wso2 cep siddhi wso2cep

No comments:

Post a Comment