<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 27/06/2011 10:38, Wolfgang Laun wrote:
    <blockquote
      cite="mid:BANLkTi=MzgPSPub5PKy5sftMpAJ5DZqm3A@mail.gmail.com"
      type="cite">I saw a commit and tried again, but the problem is
      still around.<br>
      I added a test to BackwardChainingTest - see the pull request.<br>
    </blockquote>
    I have created a jira to track this:<br>
    <a class="moz-txt-link-freetext" href="https://issues.jboss.org/browse/JBRULES-3101">https://issues.jboss.org/browse/JBRULES-3101</a><br>
    <br>
    I'm going to first write core unit tests around the rete&nbsp; dsl, as
    it's easier to test multi permutations for left/right input
    triggering and will better stop future regressions.<br>
    <br>
    commit here shows me updating the rete dsl testing engine for
    queries:<br>
<a class="moz-txt-link-freetext" href="https://github.com/droolsjbpm/drools/commit/279c9df98434d668d6adc837982a40ae6b9c97d3">https://github.com/droolsjbpm/drools/commit/279c9df98434d668d6adc837982a40ae6b9c97d3</a><br>
    <br>
    i've added a basic test to start with that shows it working for
    right then left triggering, but failing for left then right
    triggering.<br>
<a class="moz-txt-link-freetext" href="https://github.com/droolsjbpm/drools/blob/279c9df98434d668d6adc837982a40ae6b9c97d3/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeUnificationTest.nodeTestCase">https://github.com/droolsjbpm/drools/blob/279c9df98434d668d6adc837982a40ae6b9c97d3/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeUnificationTest.nodeTestCase</a><br>
    <br>
    At the same time i'm applying the fixes, which needs to be done to
    each node. In essence the code to get the memory iterator and the
    first entry for each left tuple assertion needs to be applied to
    each right object assertions and all the modifies.<br>
    <br>
    Mark
    <blockquote
      cite="mid:BANLkTi=MzgPSPub5PKy5sftMpAJ5DZqm3A@mail.gmail.com"
      type="cite"><br>
      -W<br>
      <br>
      <div class="gmail_quote">On 25 June 2011 14:10, Mark Proctor <span
          dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="border-left: 1px solid
          rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
          1ex;">
          <div text="#000000" bgcolor="#ffffff"> I have isolated the
            issue and know what it is, and why it works one way and not
            the other. In short on unification if the variable is
            unbound we need to turn off indexing for that specific join
            attempt. We do this when it's left triggered, we don't do
            this when it's right triggered. Updated the code to also do
            this on right triggering. Should have it fixed tonight.<br>
            <br>
            Thanks<br>
            <font color="#888888"> <br>
              Mark</font>
            <div>
              <div class="h5"><br>
                On 25/06/2011 12:38, Mark Proctor wrote:
                <blockquote type="cite"> ok thanks, I reproduced the
                  problem with the following below. If you change the
                  String insertion order it works. I'll get this fixed
                  over the weekend:<br>
                  &nbsp;&nbsp;&nbsp; @Test<br>
                  &nbsp;&nbsp;&nbsp; public void testQueryWithObject() throws Exception
                  {<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String str = "" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "package org.drools.test&nbsp; \n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "import java.util.List\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "import java.util.ArrayList\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "global List list\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "dialect \"mvel\"\n" +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "\n" + <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "import
                  org.drools.integrationtests.BackwardChainingTest.Q\n"
                  +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "import
                  org.drools.integrationtests.BackwardChainingTest.R\n"
                  +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "import
                  org.drools.integrationtests.BackwardChainingTest.S\n"
                  +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "query object(Object o)\n" + <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&nbsp;&nbsp;&nbsp; o := Object() \n" +&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "end\n" + <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "rule collectObjects when\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&nbsp;&nbsp; String( this == 'go1' )\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&nbsp;&nbsp; object( o; )\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "then\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&nbsp;&nbsp; list.add( o );\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "end\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "rule init when\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&nbsp;&nbsp; String( this == 'init' )\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "then\n" +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new Q(1) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new Q(5) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new Q(6) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new R(1) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new R(4) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new R(6) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new R(2) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new S(2) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new S(3) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " insert( new S(6) );\n " +<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "end\n" +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; KnowledgeBuilder kbuilder =
                  KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kbuilder.add(
                  ResourceFactory.newByteArrayResource( str.getBytes()
                  ),<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ResourceType.DRL );<br>
                  <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( kbuilder.hasErrors() ) {<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fail( kbuilder.getErrors().toString() );<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
                  <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; KnowledgeBase kbase =
                  KnowledgeBaseFactory.newKnowledgeBase();<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kbase.addKnowledgePackages(
                  kbuilder.getKnowledgePackages() );<br>
                  <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; kbase = SerializationHelper.serializeObject(
                  kbase );<br>
                  <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StatefulKnowledgeSession ksession =
                  kbase.newStatefulKnowledgeSession();<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;Integer&gt; list = new
                  ArrayList&lt;Integer&gt;();<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ksession.setGlobal( "list", list );<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ksession.insert( "go1" );<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ksession.fireAllRules();<br>
                  <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ksession.insert( "init" );<br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ksession.fireAllRules();<br>
                  <br>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println( list );<br>
                  &nbsp;&nbsp;&nbsp; } <br>
                  <br>
                  Mark<br>
                  On 25/06/2011 11:22, Wolfgang Laun wrote:
                  <blockquote type="cite">// This rule prints all
                    objects in WM.<br>
                    rule findObject<br>
                    when<br>
                    &nbsp;&nbsp;&nbsp; $o: Object()<br>
                    then<br>
                    &nbsp;&nbsp;&nbsp; System.out.println( "Object: " + $o );<br>
                    end<br>
                    <br>
                    Happily I get<br>
                    &nbsp;&nbsp;&nbsp; Object: 42<br>
                    &nbsp; &nbsp; Object: a String object<br>
                    &nbsp; &nbsp; Object:
                    org.drools.reteoo.InitialFactImpl@4dde85f0<br>
                    <br>
                    Now the query way:<br>
                    &nbsp;&nbsp;&nbsp; query object( Object o )<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o := Object()<br>
                    &nbsp;&nbsp;&nbsp; end<br>
                    &nbsp;&nbsp;&nbsp; rule findObjectByQuery<br>
                    &nbsp;&nbsp;&nbsp; when<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object( $a ; )<br>
                    &nbsp;&nbsp;&nbsp; then<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println( "Object by query: " + $a
                    );<br>
                    &nbsp;&nbsp;&nbsp; end<br>
                    <br>
                    Surprisingly, I get just one:<br>
                    &nbsp;&nbsp;&nbsp; Object by query:
                    org.drools.reteoo.InitialFactImpl@4dde85f0<br>
                    <br>
                    A marvellous effect can be observed when the
                    condition in rule<br>
                    findObjectByQuery is modified to<br>
                    &nbsp;&nbsp;&nbsp; when<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object()<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object( $a ; )<br>
                    &nbsp;&nbsp;&nbsp; then<br>
                    I'd have guessed that the above result would appear
                    repeatedly, once for each Object in WM,<br>
                    but that's not so. For N-1 facts the rule fires
                    N*(N+1)/2 times, showing the "initial object"<br>
                    N times, the first inserted object N-1 times, the
                    second one N-2 times and, finally, the last one<br>
                    once.<br>
                    Object by query: 42<br>
                    Object by query:
                    org.drools.reteoo.InitialFactImpl@4dde85f0<br>
                    Object by query: a String object<br>
                    Object by query: 100<br>
                    Object by query: 42<br>
                    Object by query:
                    org.drools.reteoo.InitialFactImpl@4dde85f0<br>
                    Object by query: a String object<br>
                    Object by query:
                    org.drools.reteoo.InitialFactImpl@4dde85f0<br>
                    Object by query: a String object<br>
                    Object by query:
                    org.drools.reteoo.InitialFactImpl@4dde85f0<br>
                    <br>
                    -W<br>
                    <pre><fieldset></fieldset>
_______________________________________________
rules-dev mailing list
<a moz-do-not-send="true" href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
                  </blockquote>
                  <br>
                  <pre><fieldset></fieldset>
_______________________________________________
rules-dev mailing list
<a moz-do-not-send="true" href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
                </blockquote>
                <br>
              </div>
            </div>
          </div>
          <br>
          _______________________________________________<br>
          rules-dev mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
          <a moz-do-not-send="true"
            href="https://lists.jboss.org/mailman/listinfo/rules-dev"
            target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
          <br>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>