[rules-users] Error in MVEL execution (optimization?)

Wolfgang Laun wolfgang.laun at gmail.com
Thu Jan 5 03:39:50 EST 2012


MVEL does not optimize. If there's any optimization, it's done by
Drools. You may see the effect of evaluations being postponed when
some term of a conjunction is false.

I agree with Mark: You haven't provided any evidence.

But I did notice something fishy - see the new thread on "MVEL
performance penalty".

-W


On 5 January 2012 01:17, Mark Proctor <mproctor at codehaus.org> wrote:
> Can't determine the problem from your posting. Maybe make a self
> contained unit test, like in MiscTest, so we can see the problem.
> https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
>
> Mark
> On 05/01/2012 00:07, ronalbury wrote:
>> I hardly got any viewers (and no responses) when I posted this just as "MVEL
>> Optimization" ... so I have changed the subject and re-posted (my apologies
>> if I just broke protocol).
>>
>>
>> I'm not sure how to explain this, other than it appears that MVEL is trying
>> to optimize the When conditions in my rules.
>>
>> I have a utility class, Test, with a number of methods on it (including null
>> protected versions of Drools "in" and "matches").  Note that the valueInList
>> method can return null (e.g. if the product code is null), and the
>> getAgeAsInt method can also return null (if the age is null).  I don't like
>> having to test if the result of the method is true, but I kept running into
>> null pointer errors in the Drools expression evaluation code and had to
>> adopt this convention.
>>
>> Here are two example rules (one in Java dialect and one in MVEL dialect).  I
>> realize that a list of one is a degenerate case for using 'inList', but it
>> should still work.
>>
>> rule "Term 15Plus Max Age - Washington"
>>          dialect "java"
>>          when
>>                  $ea : EasyApp(
>>                          Test.valueInList($ea.getEaProductCode(),
>> "L15P")==true
>>                      &&  Test.valueInList($ea.getEaIssueState(), "WA")==true
>>                      &&  $ea.getPriIns_xmPerson().getAgeAsInt()>  65
>>                      )
>>          then
>>                  $ea.addError(drools.getRule().getName());
>> end
>>
>> rule "Term 20 Max Age - New Jersey"
>>          when
>>                  $ea : EasyApp(
>>                          Test.valueInList(eaProductCode, "L20")==true
>>                      &&  Test.valueInList(eaIssueState, "NJ")==true
>>                      &&  priIns_xmPerson.ageAsInt>  64
>>                      )
>>          then
>>                  $ea.addError(drools.getRule().getName());
>> end
>>
>> I have approximately 30 different rules similar to those above.  When I have
>> the rules written in MVEL, it appears to be only be evaluating one rule per
>> EasyApp injection (I have a log message when ever valueInList is called),
>> and I get bogus results.  However, when I shift to java dialect then it
>> appears that the methods are called for each rule I have defined (as I would
>> have expected).
>>
>> Can anyone tell me if I am doing something wrong, and explain why Drools is
>> behaving as it is?
>>
>> Thanks
>>
>> --
>> View this message in context: http://drools.46999.n3.nabble.com/Error-in-MVEL-execution-optimization-tp3633440p3633440.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
>
> _______________________________________________
> 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