<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3395" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>Edson -</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>Thank you very much for the reply. I have one more
question. </FONT></SPAN><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>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).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>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:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>org.drools.RuntimeDroolsException: Exception executing
predicate <A
href="mailto:com.bah.aims.rules.Rule_my_rule_0ReturnValue0Invoker@36289b82">com.bah.aims.rules.Rule_my_rule_0ReturnValue0Invoker@36289b82</A><BR> at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:216)<BR> at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:132)<BR> at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:318)<BR> at
org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:140)<BR> at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:299)<BR> at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)<BR>...</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>Caused by: java.lang.NullPointerException<BR> at
com.bah.aims.rules.Rule_my_rule__0.returnValue0(Rule_my_rule_0.java:27)<BR> at
com.bah.aims.rules.Rule_my_rule_0ReturnValue0Invoker.evaluate(Rule_myRule_0ReturnValue0Invoker.java:21)<BR> at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:210)<BR> ...
29 more</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>I'm not sure what is causing this. Any
thoughts?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>If it helps, RulesUtil.containsKeywordString() checks
to see if a string passed in is present in a list of keywords held in the
class.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>Thanks - </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2>David</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=637335817-16092008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><FONT face=Arial color=#0000ff
size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><FONT
face=Arial color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff
size=2></FONT><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Edson
Tirelli<BR><B>Sent:</B> Tuesday, September 16, 2008 9:56 AM<BR><B>To:</B> Rules
Users List<BR><B>Subject:</B> Re: [rules-users] Request for assistance in
removing eval from a rule<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><FONT
face=Arial color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff
size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff size=2></FONT><FONT
face=Arial color=#0000ff size=2></FONT><BR>
David,<BR><BR> 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?<BR> <BR>
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.<BR><BR> Regarding evals, inline evals are just a
bit lighter than top level evals, but there is an important difference:<BR><BR>*
inline evals MUST be time consistent, i.e., they must evaluate to the same value
everytime they are called.<BR>* top level evals can deal with changes
appropriately <BR><BR> []s<BR> Edson<BR><BR>
<DIV class=gmail_quote>2008/9/15 Warren, David [USA] <SPAN dir=ltr><<A
href="mailto:warren_david@bah.com">warren_david@bah.com</A>></SPAN><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2>Folks -
</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial><FONT color=#0000ff><FONT
size=2>After <SPAN>seeing the </SPAN>thread
on <SPAN>e</SPAN>vals <SPAN>hurting performance </SPAN>a couple of
weeks ago<SPAN>, I tried to remove them from a rule set we are
using (running Drools 4.0.4), and have had limited
success.</SPAN></FONT></FONT></FONT><FONT face=Arial color=#0000ff
size=2></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>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:</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN>1. Does using inline evals (like below) hurt performance as
much as using non-inline evals?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>2. If
so, any thoughts for how to rewrite this rule to avoid using the
eval?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2></FONT> </DIV><FONT color=#0000ff size=2><FONT color=#960000
size=1>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2>rule</FONT></DIV></FONT><FONT face=Arial>'my rule'</FONT></FONT></DIV>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT
face=Arial>salience</FONT></FONT></B><FONT face=Arial> 790</FONT></DIV>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT
face=Arial>activation-group</FONT></FONT></B><FONT face=Arial> <FONT
color=#008000>"priorityRule"</FONT></FONT></DIV>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT
face=Arial>when</FONT></FONT></B></DIV>
<DIV dir=ltr align=left><FONT face=Arial>ruleUtil : RulesUtil( )</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial>s1 : Sensor( source == <FONT
color=#008000>"X</FONT>, $rfp : RFP , <B><FONT
color=#960000>eval</FONT></B></FONT><FONT face=Arial>(
ruleUtil.containsKeywordString($rfp, <FONT color=#008000>"Y"</FONT>
)<SPAN>)</SPAN> , $tcn : TCN)</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial>s2 : Sensor( TCN != $tcn, source ==
<FONT color=#008000>"Z"</FONT></FONT></DIV>
<DIV dir=ltr align=left><B><FONT color=#960000><FONT
face=Arial>then</FONT></FONT></B></DIV>
<DIV dir=ltr align=left><FONT face=Arial>System.out.println(<FONT
color=#008000>"my rule");</FONT></FONT></DIV>
<DIV dir=ltr align=left><FONT
face=Arial>priority.setPriorityName(<SPAN>"A"</SPAN></FONT><FONT
face=Arial>);</FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial></FONT> </DIV><FONT face=Arial>
<DIV dir=ltr align=left>end</DIV></FONT>
<DIV dir=ltr align=left><FONT face=Arial><FONT size=2><FONT
color=#0000ff><FONT face=Arial color=#0000ff
size=2></FONT></FONT></FONT></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN>Thanks,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN>David
Warren</SPAN></FONT></DIV><FONT face=Arial color=#0000ff size=2></FONT><FONT
face=Arial color=#0000ff size=2></FONT><BR>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf Of
</B>Edson Tirelli<BR><B>Sent:</B> Friday, September 05, 2008 2:59
PM<BR><B>To:</B> Rules Users List<BR><B>Subject:</B> Re: [rules-users] Drools,
Performance issues on 4.0.7 Vs 2.5<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr><BR> 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.<BR><BR> As an example, look at
this: <A
href="http://blog.athico.com/2006/11/rush-hour-and-content-based-routing.html"
target=_blank>http://blog.athico.com/2006/11/rush-hour-and-content-based-routing.html</A><BR><BR>
[]s<BR> Edson<BR><BR>
<DIV class=gmail_quote>2008/9/5 Rout, Sushanta (ThoughtMill) <SPAN
dir=ltr><<A href="mailto:Sushanta.Rout@ihg.com"
target=_blank>Sushanta.Rout@ihg.com</A>></SPAN><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">We
were using Drools 2.5 version earlier. Now we have switched to drools<BR><A
href="http://4.0.7." target=_blank>4.0.7.</A> But we see significant issues
with performance like drools 4.0.7<BR>is three times slower than 2.5 . Has
anybody encountered the issue?<BR><BR>Here is a sample of the rule, we have
some more similar to this.<BR>rule "test"<BR>
dialect "java"<BR> activation-group
"group1"<BR> when<BR>
$croNumberDetailsRequest :
CRONumberDetailsRequest()<BR>
$resdirectPhoneNumber : ResdirectPhoneNumber()<BR>
eval($resdirectPhoneNumber.getType().getId() == 5
&&<BR><BR>$resdirectPhoneNumber.isValidForBrand($croNumberDetailsRequest.getBrand(<BR>))
&&<BR>
$croNumberDetailsRequest.getRegion() != null
&&<BR><BR>$resdirectPhoneNumber.isValidRegion($croNumberDetailsRequest.getRegion()<BR>)
&&<BR>
$croNumberDetailsRequest.getLocale() != null
&&<BR><BR><BR>$resdirectPhoneNumber.isValidForLocaleId($croNumberDetailsRequest.getLoc<BR>ale())
&&<BR><BR>$resdirectPhoneNumber.isValidSlot($croNumberDetailsRequest.getSlot()));<BR><BR>
then<BR>
ResultList.add($resdirectPhoneNumber);<BR>end<BR><BR>_______________________________________________<BR>rules-users
mailing list<BR><A href="mailto:rules-users@lists.jboss.org"
target=_blank>rules-users@lists.jboss.org</A><BR><A
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Edson Tirelli<BR>JBoss Drools Core Development<BR>JBoss,
a division of Red Hat @ <A href="http://www.jboss.com"
target=_blank>www.jboss.com</A><BR></DIV><BR>_______________________________________________<BR>rules-users
mailing list<BR><A
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR><A
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Edson Tirelli<BR>JBoss Drools Core Development<BR>JBoss, a
division of Red Hat @ <A
href="http://www.jboss.com">www.jboss.com</A><BR></DIV></BODY></HTML>