<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";
        color:black;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
pre
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-US link=blue vlink=blue>

<div class=Section1>

<div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>Thanks, Mark. Are there any plans on making return
value, predicate and eval expressions indexable (in case it is possible at
all)? Would it be included in 3.2 release? I understand that DROOLS can not
guarantee that helper method will return the same value each time and probably
that&#8217;s why excludes such cases from index, but the same goes for &#8216;getters&#8217;
of the fact objects &#8211; DROOLS can&#8217;t guarantee the getter will return
the same value each time, so it just have to assume it (and it is outlined in
the documentation).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>There are a few use case that might need this kind of
functionality, eg to cache the results of &#8216;associative&#8217; lookup.
Especially for the &#8216;Decision Tables&#8217;. The problem I&#8217;m facing
right now is I need to &#8216;expand&#8217; the list of codes based on some id
and use those codes as constraint:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyObject(field
&lt;= LookupMap.getCodes($param))<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>Where $param is a value from Decision Table data. In
this particular case a set of, say 100 codes, can be described with a simple
ID. For more complex cases a pseudo &#8216;set select&#8217; expression can be
passed as a parameter (eg, LookupMap.getCodes(&#8220;groupId_1 &#8211; grouperId_2&#8221;),
which should return the intersection of codes in groupId_1 and groupId_2). In
any case, the &lt;key, value&gt; pairs returned by LookupMap class would remain
the same.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>Vlad<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New Roman"><span style='font-size:12.0pt;color:windowtext'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
size=2 color=black face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma;
color:windowtext'> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Mark Proctor<br>
<b><span style='font-weight:bold'>Sent:</span></b> 12 February 2007 19:16<br>
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">Rules
 Users List</st1:PersonName><br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [rules-users] calls
to 'Helper' classes in LHS - are they allowed?</span></font><font color=black><span
style='color:windowtext'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>We were hoping the community would work with us and
improve the documentation over the last year - to date we have had zip :( We
will have another documentation drive once we get to the candidate release
stage for the current development cycle. We simply don't have the cycles to
work on a book, with any luck after we spend 3 to 4 weeks on documentation
during hte candidate release stage it should get better, and maybe one
day&nbsp; the manual can form the basis of a book. Some ideas for the&nbsp;
community to work include the examples in drools-examples, they can even use
what I did for drools 2.x as a starting basis, or to provide a really good
tutorial on the basics of pattern matching, you can look the public domain
clips manual for pointers here. It's not money we need, its time, YOUR time :)<br>
<br>
If you want to use a helper class it must be in a return value, predicate or
eval - none of which are currently indexed. return value and predicate must
also be time constant, eval does not have to be.<br>
<br>
Mark<br>
Michael Suzio wrote: <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>I see this in the docs:<br>
<br>
&quot;A <a name=d0e1997 moz-do-not-send=true></a>Predicate constraint can use
any valid Java expression as long as it evaluated to a primitive boolean - avoid
using any Drools keywords as Declaration identifiers. Previously bound
declarations can be used in the expression. Functions used in a Predicate
Constraint must return time constant results.&quot;<br>
<br>
and under the discussion of 'eval':<br>
<br>
&quot;Evals cannot be indexed and thus are not as optimal as using Field
Constraints.&quot;<br>
<br>
and this in general discussion of constraints and accessors of your objects
used in them:<br>
<br>
&quot;Do please make sure that you are accessing methods that take no
parameters, and are in-fact &quot;accessors&quot; (as in, they don't change the
state of the object in a way that may effect the rules - remember that the rule
engine effectively caches the results of its matching inbetween invocations to
make it faster).&quot;<br>
<br>
So, if invoking a helper method is like an eval, I'm thinking Drools computes
the match, but then throws it away because it knows this is not a constant
expression.&nbsp; Whereas, if it were just a match of an accessor's value vs. a
constant String, it could cache that. <br>
<br>
I'm wildly speculating, only because I want to understand fully what is
happening, so I'm throwing stuff out there so the Drools team will have to
correct my misapprehensions before I confuse the whole list (*g*).&nbsp;
Sometimes reading the Drools documentation is like a Talmudic scholar trying to
find the deeper meaning of the sacred words...&nbsp; as much as I want the 3.2
milestone, I want real documentation even more (and *hint hint* -- would
probably be willing to pay for it, guys!&nbsp; Can we get an O'Reilly book?)<br>
<br>
&nbsp; --- Michael<br>
<br>
<o:p></o:p></span></font></p>

<span id="q_110b81fae178c623_1"></span>

<div>

<p class=MsoNormal><span class=gmailquote><font size=3 color=black
face="Times New Roman"><span style='font-size:12.0pt'>On 2/12/07, <b><span
style='font-weight:bold'>Steven Williams</span></b> &lt;<a
href="mailto:stevenw@objectconsulting.com.au" moz-do-not-send=true>stevenw@objectconsulting.com.au</a>&gt;
wrote:</span></font></span> <o:p></o:p></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>I believe there is a caveat on functions and helper
methods called from the LHS that they need to be constant over time (or at
least over the life of the working memory) which then allows matches to be
computed as per normal. <br>
<br>
Steve <o:p></o:p></span></font></p>

<div><span id="q_110b81fae178c623_1">

<p class=MsoNormal style='margin-bottom:12.0pt'><span class=e><font size=3
color=black face="Times New Roman"><span style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></span></p>

<div>

<p class=MsoNormal><span class=gmailquote><font size=3 color=black
face="Times New Roman"><span style='font-size:12.0pt'>On 2/13/07, <b><span
style='font-weight:bold'>Michael Suzio</span></b> &lt;<a
href="mailto:msuzio@gmail.com" target="_blank" moz-do-not-send=true>
msuzio@gmail.com</a>&gt; wrote:</span></font></span> <o:p></o:p></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>The JBoss guys can correct me if I'm wrong, but
although I think that works, what you've just done is eliminate any chance to
precompute matches and trim down the checks that need to happen to find a rule
match.&nbsp; Since the engine can't know that Helper.transform(&quot;value&quot;)
returns a constant value, it has to re-run that every time and it has to reject
for matches to the rule constraint every time.<br>
<br>
I'm sure this would really sink performance, in other words.&nbsp; You can
easily see the effect -- write the rule this way and time it, and then write it
with the return value of Helper.transform being inlined, and I'm sure there's a
big difference.&nbsp; It's the same as any other eval(...) situation in Drools;
possible, but not good for performance. <o:p></o:p></span></font></p>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3 color=black
face="Times New Roman"><span style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><span class=gmailquote><font size=3 color=black
face="Times New Roman"><span style='font-size:12.0pt'>On 2/12/07, <b><span
style='font-weight:bold'>Olenin, Vladimir (MOH)</span></b> &lt;<a
href="mailto:Vladimir.Olenin@moh.gov.on.ca" target="_blank"
moz-do-not-send=true>Vladimir.Olenin@moh.gov.on.ca</a>&gt; wrote: </span></font></span><o:p></o:p></p>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>Hi,<br>
<br>
I was wondering if calls to a Helper class are allowed in LHS of the rule?<br>
Eg:<br>
<br>
Rule myRule<br>
When<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyObject(objField ==
Helper.transform(&quot;value&quot;))<br>
Then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // smth<br>
End <br>
<br>
<br>
Thanks,<br>
<br>
Vlad<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank"
moz-do-not-send=true>rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"
moz-do-not-send=true>https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3 color=black
face="Times New Roman"><span style='font-size:12.0pt'><br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank"
moz-do-not-send=true>rules-users@lists.jboss.org </a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"
moz-do-not-send=true>https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><br>
<br clear=all>
<br>
<br>
<o:p></o:p></span></font></p>

</div>

</span>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3 color=black
face="Times New Roman"><span style='font-size:12.0pt'>-- <br>
Steven Williams<br>
<br>
Supervising Consultant<br>
<br>
Object Consulting<br>
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501<br>
<a href="mailto:stevenw@objectconsulting.com.au" target="_blank"
moz-do-not-send=true>stevenw@objectconsulting.com.au </a><br>
<a href="http://www.objectconsulting.com.au" target="_blank"
moz-do-not-send=true>www.objectconsulting.com.au</a><br>
<br>
consulting | development | training | support<br>
our experience makes the difference <br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" moz-do-not-send=true>rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank"
moz-do-not-send=true>https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><br>
<br>
<o:p></o:p></span></font></p>

<pre><font size=2 color=black face="Courier New"><span style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'>

<hr size=4 width="90%" align=center>

</span></font></pre><pre><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>_______________________________________________<o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>rules-users mailing list<o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>&nbsp; <o:p></o:p></span></font></pre>

<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>