[rules-users] averages on different data types

Chris Richmond crichmond at referentia.com
Wed Jun 17 19:49:45 EDT 2009


Ok..I was under the impression that the rule would fire for each Order
object that was injected, and in that case variables apply to each Order,
hence accessing them from the consequences(right side) would be from an
indfividual Order.  I guess I am misundertanding how it works.

 

Thanks for the clarification.

 

Chris

 

  _____  

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Wednesday, June 17, 2009 1:37 PM
To: Rules Users List
Subject: Re: [rules-users] averages on different data types

 


   Chris,

   Not sure what you mean. If you want to know what is in there for debug
purposes, I guess the best way is to implement your own average() accumulate
function that prints out (or do whatever you want) with the bound
variables/facts.

   For regular use, it does not makes sense to allow access to such variable
because it is bound to multiple values. For instance:

$tot : Number() from accumulate( 
    Order( $value : value ),
    sum( $value ) )

    This pattern will sum all the values from all the Order facts in the
working memory. Lets imagine that it would be possible to access the $value
variable outside the accumulate, what Order would it be bound to? So, it
makes no sense...

     []s
     Edson

2009/6/17 Chris Richmond <crichmond at referentia.com>

So how can I access variables that I have populated from within that scope
delimiter(accumulate)?  For instance if I did want to access the delayTime,
what strategy should be used?

 

Thanks,


Chris

  _____  

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Wednesday, June 17, 2009 11:49 AM
To: Rules Users List
Subject: Re: [rules-users] averages on different data types

 


   Chris,

   Remember that accumulate is a scope delimiter, meaning variables bound
inside accumulate are not visible outside of it. The error message you see
is the MVEL way of saying: non-existing variable (I guess you are using mvel
as the dialect for the consequence).

   If you want to know what data objects are being inserted/expired from the
working memory, use a working memory listener.

   []s
   Edson

2009/6/17 Chris Richmond <crichmond at referentia.com>

Hi guys,

 

Building from the stockticker sample, I have been running my own average
aggregates over time and window length and I have the following rule.it
simply runs a last 10 average and outputs the average(in theory). 

 

rule "show averages"

when

 

            $n : Number( doubleValue > 0 ) from accumulate (

 

 

 

            $mdo : MyDataObject($tm: delayTime) over window:length(10) from
entry-point "DataObject stream",

            average( $tm )

 

        )

 

 

then

 

    System.err.println($tm);

 

End

 

I have set the limit to 0 for the average because I simply want to have it
fire every time, no matter the average(they are all positive)

 

 

However I get this error:

 

Unable to build expression for 'consequence': Failed to compile: 1
compilation error(s): 

 - (1,3) unqualified type in strict mode for: $tm '

    System.err.println($tm);

' : [Rule name='show averages']

 

 

If I have the consequence 

 

System.err.println($n);

 

Then it outputs the average no problem, but I am trying to simply output
that indifidual value, delayTime which I have stored in $tm is an integer,
so I cannot figure out why I cannot output this value.    Similarly if I
simply try as a consequence:

 

System.err.println($ mdo.delayTime);

 

I get a similar error.

 

What am I doing wrong?

 

Thanks,


Chris


_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com


_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090617/a40cc8e8/attachment.html 


More information about the rules-users mailing list