&nbsp;&nbsp; Prem,<br><br>&nbsp;&nbsp; I understand your concern about == (identity) check agains the equals() check. However, I think you should first try using the &quot;==&quot; (equals) check and let the engine index your facts and then, if you still see performance problems, we look into alternatives. Remember that the identity check will give you performance gains if you do a lot of comparisons, but with indexed facts, the actual comparisons will be just a few (possible a single comparison for each constraint for each rule), so I think the gains will not be perceptible.
<br><br>&nbsp;&nbsp; If you were using a predicate to execute the equals() so far, chances are that you were seing a very poor performance. <br>&nbsp;&nbsp; Use the regular constraint as we discussed, see the difference and then we dig deeper if needed.
<br><br>&nbsp;&nbsp; Now, answering your question, you can&#39;t do identity checks in the rules language without using a predicate or eval to fall back into java code. But, if you do that, you lose the facts indexing feature.<br><br>
&nbsp;&nbsp;&nbsp; Send us a sample rule if you are not sure it is written in a way it uses the engine optimization features and we may try to help you.<br><br>&nbsp;&nbsp;&nbsp; Regards<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/3/26, Premkumar Stephen &lt;
<a href="mailto:prem18@gmail.com">prem18@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks Edson for clarifying that in DRL, the &quot;==&quot; is the equals() method.
<br>However, as this is not the case with java, can I tell the engine that &quot;==&quot; means &quot;==&quot; and not &quot;equals()&quot;?
<br><br>While the &quot;equals()&quot; will not return a wrong value, in my case, it might be more expensive than &quot;==&quot;<br><br>Regards,<br>Prem<div><span class="e" id="q_11190e37a55e99d4_1"><br><br><br><div><span class="gmail_quote">
On 3/26/07, <b class="gmail_sendername">
Edson Tirelli</b> &lt;<a href="mailto:tirelli@post.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">tirelli@post.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>&nbsp;&nbsp; Prem,<br><br>&nbsp;&nbsp; I think you may be misunderstanding something. In DRL language, &quot;==&quot; is the equals() method. So, if you write a rule:<br><br>rule A<br>when<br>&nbsp;&nbsp;&nbsp; UserId( name == &quot;ABC&quot; )<br>then
<br>
&nbsp;&nbsp;&nbsp; // do something<br>end<br><br>&nbsp;&nbsp; What the engine will do behind the scenes is name.equals(&quot;ABC&quot;). So, don&#39;t be afraid of doing that.<br><br>&nbsp;&nbsp; Also, &quot;huge&quot; means don&#39;t worry about it. :) You will get something like log(n) comparisons in the worst case, so, leave that to the engine.
<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/3/26, Premkumar Stephen &lt;<a href="mailto:prem18@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">prem18@gmail.com</a>

&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><span>
Hi Edson,<br><br>Thanks for your reply.<br><br>WRT your reply below (highlighted):<br>In our environment, we only have one class and several instances of that class.<br><br>We currently do not use the &quot;==&quot; constraint and we do a equals() on the name string. However, I am going to use &quot;==&quot; since there will be only one object with a particular name.
<br><br>Also, can you define what the number for &quot;huge&quot; is? How many buckets get defined initially for the hashing. Can I modify the initial size of this collection so that I will not have clashes. ( I happen to know exactly how many objects will be thrown into the engine)
<br><br>Is this set through configuration or would I have to recompile code to do this?<br><br>Thanks,<br>Prem<br><br><div><span class="gmail_quote">On 3/23/07, <b class="gmail_sendername">Edson Tirelli</b> &lt;<a href="mailto:tirelli@post.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">



tirelli@post.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>&nbsp;&nbsp; Stephen,<br><br>&nbsp;&nbsp; <span style="font-weight: bold;">



As long as you use an &quot;==&quot; constraint as your example shows</span>, the<br>first alternative will be more performatic. This is because drools<br>indexes facts based on your constraints. So, your first case will
<br>
require a single &quot;==&quot; comparison to find user name &quot;A&quot; and a single<br>comparison to find user name &quot;B&quot;. <span style="font-weight: bold; background-color: rgb(255, 255, 102);">Of course, if you have huge amound of
</span><br style="font-weight: bold; background-color: rgb(255, 255, 102);"><span style="font-weight: bold; background-color: rgb(255, 255, 102);">objects where hashcode for name start to clash, you may have more than</span>



<br style="font-weight: bold; background-color: rgb(255, 255, 102);"><span style="font-weight: bold; background-color: rgb(255, 255, 102);">one comparison,</span> but the effect is negligible when compared to all other<br>



costs of having that many facts.<br><br>&nbsp;&nbsp; Second alternative works and will also hash object types, but it will<br>create a lot more infrastructure classes and Rete Nodes to deal with<br>your 500 different classes. So it is a worst alternative for the
<br>proposed scenario.<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><br>Premkumar Stephen wrote:<br><br>&gt; Hi,<br>&gt;<br>&gt; Consider that I have 500 instances of interface userI. Now, there are<br>&gt; 3000 rules currently written based on a combination of these instances.
<br>&gt;<br>&gt; if {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$a : userI (name = &quot;A&quot;)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$b : userI (name = &quot;B&quot;)<br>&gt; }<br>&gt; then<br>&gt; {<br>&gt;&nbsp;&nbsp;//do some actions<br>&gt; }<br>&gt;<br>&gt; How many tests are needed for a match in the RETE network for this rule?
<br>&gt;<br>&gt; If I created 500 classes, one for each object, such as UserA<br>&gt; implements userI and so on... my rule will look like:<br>&gt;<br>&gt; if {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$a : UserA()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$b : UserB()<br>&gt; }
<br>&gt; then<br>&gt; {<br>&gt;&nbsp;&nbsp;//do some actions<br>&gt; }<br>&gt;<br>&gt; Will this lead to better performance since there will only be one such<br>&gt; instance of this object?<br>&gt;<br>&gt; As for class-loading concerns, will there be a parsing/memory penalty
<br>&gt; to be paid for having 500 classes now instead of one?<br>&gt;<br>&gt; Thanks!<br>&gt;<br>&gt;------------------------------------------------------------------------<br>&gt;<br>&gt;_______________________________________________
<br>&gt;rules-users mailing list<br>&gt;<a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org</a><br>&gt;<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">


https://lists.jboss.org/mailman/listinfo/rules-users
</a><br>&gt;<br>&gt;<br><br><br>--<br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3124-6000<br> Mobile: +55 11 9218-4151<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">



www.jboss.com</a><br><br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">


rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><span><br><br clear="all"><br>-- <br>Regards,<br>Prem
</span><br></span></div>_______________________________________________<span><br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

rules-users@lists.jboss.org</a>
<br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></span></blockquote>

</div><div><span>
<br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3124-6000<br>&nbsp;&nbsp;Mobile: +55 11 9218-4151<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">


www.jboss.com</a>
</span></div><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rules-users@lists.jboss.org
</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br></blockquote></div>

<br><br clear="all"><br>-- <br>Regards,<br>Prem
</span></div><br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" 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>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3124-6000<br>&nbsp;&nbsp;Mobile: +55 11 9218-4151<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">
www.jboss.com</a>