[rules-users] CEP accumulate unclear behavior
Wolfgang Laun
wolfgang.laun at gmail.com
Wed Dec 4 14:08:40 EST 2013
On 04/12/2013, ters <ters at ukr.net> wrote:
> laune, thanks for explanations.
>
> Could you please provide me with links/examples of how to /write your own
> accumulate function (using the
> init/action/result paradigm) /, and how to use this custom function instead
> of standard one?
rule manacc
when
Number( $avg: intValue )
from accumulate( Event( $source: source, $value: value),
init( int sum = 0; int count = 0; )
action( if( "server1".equals( $source ) ){
sum += $value; count++;
} )
result( count != 0 ? sum/count : 0 ) )
then
System.out.println("$events avg value = " + $avg );
end
You could add a
reverse( if( "server1".equals( $source ) ){
sum -= $value; count--;
})
Cheers
Wolfgang
>
> Regards!
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/CEP-accumulate-unclear-behavior-tp4027069p4027090.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list