<!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 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"><<a moz-do-not-send="true"
href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>></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>
@Test<br>
public void testQueryWithObject() throws Exception
{<br>
String str = "" +<br>
"package org.drools.test \n" +<br>
<br>
"import java.util.List\n" +<br>
"import java.util.ArrayList\n" +<br>
<br>
"global List list\n" +<br>
<br>
"dialect \"mvel\"\n" + <br>
"\n" + <br>
<br>
"import
org.drools.integrationtests.BackwardChainingTest.Q\n"
+<br>
"import
org.drools.integrationtests.BackwardChainingTest.R\n"
+<br>
"import
org.drools.integrationtests.BackwardChainingTest.S\n"
+ <br>
<br>
"query object(Object o)\n" + <br>
" o := Object() \n" + <br>
"end\n" + <br>
<br>
"rule collectObjects when\n" +<br>
" String( this == 'go1' )\n" +<br>
" object( o; )\n" +<br>
"then\n" +<br>
" list.add( o );\n" +<br>
"end\n" +<br>
<br>
<br>
"rule init when\n" +<br>
" String( this == 'init' )\n" +<br>
"then\n" +<br>
" insert( new Q(1) );\n " +<br>
" insert( new Q(5) );\n " +<br>
" insert( new Q(6) );\n " +<br>
" insert( new R(1) );\n " +<br>
" insert( new R(4) );\n " +<br>
" insert( new R(6) );\n " +<br>
" insert( new R(2) );\n " +<br>
" insert( new S(2) );\n " +<br>
" insert( new S(3) );\n " +<br>
" insert( new S(6) );\n " +<br>
"end\n" + <br>
""; <br>
<br>
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
kbuilder.add(
ResourceFactory.newByteArrayResource( str.getBytes()
),<br>
ResourceType.DRL );<br>
<br>
if ( kbuilder.hasErrors() ) {<br>
fail( kbuilder.getErrors().toString() );<br>
}<br>
<br>
KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase();<br>
kbase.addKnowledgePackages(
kbuilder.getKnowledgePackages() );<br>
<br>
kbase = SerializationHelper.serializeObject(
kbase );<br>
<br>
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();<br>
List<Integer> list = new
ArrayList<Integer>();<br>
ksession.setGlobal( "list", list );<br>
<br>
ksession.insert( "go1" );<br>
ksession.fireAllRules();<br>
<br>
ksession.insert( "init" );<br>
ksession.fireAllRules();<br>
<br>
System.out.println( list );<br>
} <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>
$o: Object()<br>
then<br>
System.out.println( "Object: " + $o );<br>
end<br>
<br>
Happily I get<br>
Object: 42<br>
Object: a String object<br>
Object:
org.drools.reteoo.InitialFactImpl@4dde85f0<br>
<br>
Now the query way:<br>
query object( Object o )<br>
o := Object()<br>
end<br>
rule findObjectByQuery<br>
when<br>
object( $a ; )<br>
then<br>
System.out.println( "Object by query: " + $a
);<br>
end<br>
<br>
Surprisingly, I get just one:<br>
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>
when<br>
Object()<br>
object( $a ; )<br>
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>