I must be missing something. If you want to check if all the three strings are present in each array, why are you using OR (||)?<div><br></div><div>If you don't want to model the array as a class containing the "parent" reference and insert them as facts, you can try this:</div>
<div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div><br></div><div>MyContext(classes contains "TestString1" && contains "TestString2" && contains "TestString3")</div>
</span></div><div><br></div><div><br></div><div>Best Regards,<br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>
- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Wed, Sep 29, 2010 at 12:17 PM, Swindells, Thomas <span dir="ltr"><<a href="mailto:TSwindells@nds.com" target="_blank">TSwindells@nds.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>> Thomas, Thanks for the suggestions.<br>
><br>
> Swindells, Thomas wrote:<br>
> ><br>
> > Also have you tried just using ==, eg exists( String(this ==<br>
> > "TestString1") || String(this == "TestString2") || String(this ==<br>
> > "TestString3") from DclassesList)<br>
> ><br>
><br>
> This did reduce the time by about 50 ms.<br>
</div>That's a step in the right direction at least.<br>
<div><br>
> Swindells, Thomas wrote:<br>
> ><br>
> ><br>
> > You may also want to consider whether it would be beneficial to<br>
> > restructure your fact class to get rid of the from, and match against<br>
> > ClassName facts instead - this may give you a big performance gain as it<br>
> > means each rule wouldn't have to iterate over the list, if you are<br>
> > updating MyContext then this gain is likely to be even bigger.<br>
> ><br>
><br>
> Not quite sure about what you mean by "match against ClassName facts instead<br>
> ". My fact class will have a bunch of instance variables one of which is<br>
> the array of strings.<br>
> Would be great if you could elaborate that a bit.<br>
<br>
</div>Have two fact classes,<br>
One is your current fact class (MyContext), the other is to represent each of your classes entry.<br>
Eg:<br>
Class ClassName {<br>
MyContext parent;<br>
String name;<br>
...<br>
}<br>
<br>
When inserting you MyContext into the working memory you would also add a ClassName fact for each entry of the classes list (you could either do this in code or have a rule which does it for you).<br>
<br>
Your main rules would then look something like the following:<br>
<br>
<br>
Rule XYZ<br>
$parent : MyContext<br>
exists ( ClassName(parent == $parant, name == "TestString1") or ClassName(parent == $parant, name == "TestString2") or ClassName(parent == $parant, name == "TestString3"))<br>
then<br>
...<br>
<br>
If you only ever have one MyContext in working memory you can skip the parent check.<br>
<br>
<br>
You may also be able to use in to simplify things<br>
exists ( ClassName(parent == $parant, name in {"TestString1", "TestString2", "TestString3"))<br>
<br>
<br>
Hope that makes sense,<br>
<font color="#888888"><br>
Thomas<br>
</font><div><br>
<br>
<br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the <a href="mailto:postmaster@nds.com" target="_blank">postmaster@nds.com</a> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
<br>
</div><div><div></div><div>_______________________________________________<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>
</div></div></blockquote></div><br>
</div>