Thanks Edson for clarifying that in DRL, the "==" is the equals() method.<br>However, as this is not the case with java, can I tell the engine that "==" means "==" and not "equals()"?
<br><br>While the "equals()" will not return a wrong value, in my case, it might be more expensive than "=="<br><br>Regards,<br>Prem<br><br><br><div><span class="gmail_quote">On 3/26/07, <b class="gmail_sendername">
Edson Tirelli</b> <<a href="mailto:tirelli@post.com">tirelli@post.com</a>> 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> Prem,<br><br> I think you may be misunderstanding something. In DRL language, "==" is the equals() method. So, if you write a rule:<br><br>rule A<br>when<br> UserId( name == "ABC" )<br>then
<br>
// do something<br>end<br><br> What the engine will do behind the scenes is name.equals("ABC"). So, don't be afraid of doing that.<br><br> Also, "huge" means don't worry about it. :) You will get something like log(n) comparisons in the worst case, so, leave that to the engine.
<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2007/3/26, Premkumar Stephen <<a href="mailto:prem18@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">prem18@gmail.com</a>
>:</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 class="e" id="q_11190b163ee36fcd_1">
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 "==" constraint and we do a equals() on the name string. However, I am going to use "==" since there will be only one object with a particular name.
<br><br>Also, can you define what the number for "huge" 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> <<a href="mailto:tirelli@post.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
tirelli@post.com</a>> 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> Stephen,<br><br> <span style="font-weight: bold;">
As long as you use an "==" 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 "==" comparison to find user name "A" and a single<br>comparison to find user name "B". <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> 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> []s<br> Edson<br><br><br>Premkumar Stephen wrote:<br><br>> Hi,<br>><br>> Consider that I have 500 instances of interface userI. Now, there are<br>> 3000 rules currently written based on a combination of these instances.
<br>><br>> if {<br>> $a : userI (name = "A")<br>> $b : userI (name = "B")<br>> }<br>> then<br>> {<br>> //do some actions<br>> }<br>><br>> How many tests are needed for a match in the RETE network for this rule?
<br>><br>> If I created 500 classes, one for each object, such as UserA<br>> implements userI and so on... my rule will look like:<br>><br>> if {<br>> $a : UserA()<br>> $b : UserB()<br>> }
<br>> then<br>> {<br>> //do some actions<br>> }<br>><br>> Will this lead to better performance since there will only be one such<br>> instance of this object?<br>><br>> As for class-loading concerns, will there be a parsing/memory penalty
<br>> to be paid for having 500 classes now instead of one?<br>><br>> Thanks!<br>><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>><br>><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 class="q"><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 class="e" id="q_11190b163ee36fcd_5">
<br><br clear="all"><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>
</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>Regards,<br>Prem