Edson -
Thanks for the reply. I am setting the global prior to calling the
rules.
That said, I was able to fix my problem by removing the evals from my
rules, using the method described by Mohammed Riyaz in a post yesterday
(thanks Mohammed!). Removing the evals also remedied a problem we were
seeing where our rules using evals would occasionally fail due to null
pointer exceptions throw by PredicateConstraint when being run by a
multi-thread job (very similar to what's noted in issue JBRULES-1751).
I defined all the methods in our RulesUtil class as static, imported the
functions, and referenced them inside an exists() clause like this:
exists( Boolean( booleanValue==true) from containsKeyword($myString) )
-David
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Tuesday, September 16, 2008 7:26 PM
To: Rules Users List
Subject: Re: [rules-users] Request for assistance in removing eval from
a rule
Are use setting the global in your application code?
2008/9/16 Warren, David [USA] <warren_david(a)bah.com>
Edson -
Thank you very much for the reply. I have one more question.
In the example below I changed RulesUtil to be a global name 'ruleUtil'
(since its member variables do not change), and reran the rule (with the
'ruleUtil:RulesUtil()' line omitted).
When I do this, and execute the rule below, I get a null pointer
exception on PredicateConstraint. The first and last parts of the stack
trace are:
org.drools.RuntimeDroolsException: Exception executing predicate
com.bah.aims.rules.Rule_my_rule_0ReturnValue0Invoker@36289b82
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:2
16)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:132)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:318)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:140)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:299)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
...
Caused by: java.lang.NullPointerException
at
com.bah.aims.rules.Rule_my_rule__0.returnValue0(Rule_my_rule_0.java:27)
at
com.bah.aims.rules.Rule_my_rule_0ReturnValue0Invoker.evaluate(Rule_myRul
e_0ReturnValue0Invoker.java:21)
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:2
10)
... 29 more
I'm not sure what is causing this. Any thoughts?
If it helps, RulesUtil.containsKeywordString() checks to see if
a string passed in is present in a list of keywords held in the class.
Thanks -
David
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Tuesday, September 16, 2008 9:56 AM
To: Rules Users List
Subject: Re: [rules-users] Request for assistance in removing
eval from a rule
David,
Eval is really bad for perf, but still, sometimes it is the
only way to do things like call methods. So, in your case, it all
depends on what "containsKeywordString()" method is doing?
Also, is RulesUtil just a utility class? I mean with no data
you reason over? if so, I strongly advise you to make it a global,
instead of matching it in the rule like a fact.
Regarding evals, inline evals are just a bit lighter than top
level evals, but there is an important difference:
* inline evals MUST be time consistent, i.e., they must evaluate
to the same value everytime they are called.
* top level evals can deal with changes appropriately
[]s
Edson
2008/9/15 Warren, David [USA] <warren_david(a)bah.com>
Folks -
After seeing the thread on evals hurting performance a
couple of weeks ago, I tried to remove them from a rule set we are using
(running Drools 4.0.4), and have had limited success.
An example is shown below. We're using evals every time
we make a call to "rulesUtil", a helper class we have for checking
strings for keywords. Two questions:
1. Does using inline evals (like below) hurt performance
as much as using non-inline evals?
2. If so, any thoughts for how to rewrite this rule to
avoid using the eval?
rule
'my rule'
salience 790
activation-group "priorityRule"
when
ruleUtil : RulesUtil( )
s1 : Sensor( source == "X, $rfp : RFP , eval(
ruleUtil.containsKeywordString($rfp, "Y" )) , $tcn : TCN)
s2 : Sensor( TCN != $tcn, source == "Z"
then
System.out.println("my rule");
priority.setPriorityName("A");
end
Thanks,
David Warren
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Friday, September 05, 2008 2:59 PM
To: Rules Users List
Subject: Re: [rules-users] Drools, Performance issues on
4.0.7 Vs 2.5
Start by eliminating the evals and writing your
constraints properly inside the patterns. Drools 3+ is orders of
magnitude faster than Drools 2.x, but you need to leverage its power in
your rules. Please read the manual as the version 3 was a completely
rewrite of version 2. Version 4 is an improvement over 3.
As an example, look at this:
http://blog.athico.com/2006/11/rush-hour-and-content-based-routing.html
[]s
Edson
2008/9/5 Rout, Sushanta (ThoughtMill)
<Sushanta.Rout(a)ihg.com>
We were using Drools 2.5 version earlier. Now we
have switched to drools
4.0.7. But we see significant issues with
performance like drools 4.0.7
is three times slower than 2.5 . Has anybody
encountered the issue?
Here is a sample of the rule, we have some more
similar to this.
rule "test"
dialect "java"
activation-group "group1"
when
$croNumberDetailsRequest :
CRONumberDetailsRequest()
$resdirectPhoneNumber :
ResdirectPhoneNumber()
eval($resdirectPhoneNumber.getType().getId() == 5 &&
$resdirectPhoneNumber.isValidForBrand($croNumberDetailsRequest.getBrand(
)) &&
$croNumberDetailsRequest.getRegion() != null &&
$resdirectPhoneNumber.isValidRegion($croNumberDetailsRequest.getRegion()
) &&
$croNumberDetailsRequest.getLocale() != null &&
$resdirectPhoneNumber.isValidForLocaleId($croNumberDetailsRequest.getLoc
ale()) &&
$resdirectPhoneNumber.isValidSlot($croNumberDetailsRequest.getSlot()));
then
ResultList.add($resdirectPhoneNumber);
end
_______________________________________________
rules-users mailing list
rules-users(a)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(a)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(a)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