[jboss-jira] [JBoss JIRA] (DROOLS-1404) Alpha node not shared with static function evaluation
Matteo Mortari (JIRA)
issues at jboss.org
Fri Jan 13 10:43:00 EST 2017
[ https://issues.jboss.org/browse/DROOLS-1404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13348130#comment-13348130 ]
Matteo Mortari edited comment on DROOLS-1404 at 1/13/17 10:42 AM:
------------------------------------------------------------------
Following test when placed in Misc2Test exhibit the problem:
{code:java}
public static class TestStaticUtils {
public static int return1() {
return 1;
}
}
@Test
public void testShouldAlphaShareBecauseSameConstantDespiteDifferentSyntax() {
String drl1 = "package c;\n" +
"import " + TestObject.class.getCanonicalName() + "\n" +
"rule fileArule1 when\n" +
" TestObject(value == 1)\n" +
"then\n" +
"end\n" +
"";
String drl2 = "package iTzXzx;\n" + // <<- keep the different package
"import " + TestObject.class.getCanonicalName() + "\n" +
"import " + TestStaticUtils.class.getCanonicalName() + "\n" +
"rule fileBrule1 when\n" +
" TestObject(value == TestStaticUtils.return1() )\n" +
"then\n" +
"end\n" +
"rule fileBrule2 when\n" + // <<- keep this rule
" TestObject(value == 0 )\n" +
"then\n" +
"end\n" +
"";
KieSession kieSession = new KieHelper()
.addContent(drl1, ResourceType.DRL)
.addContent(drl2, ResourceType.DRL)
.build().newKieSession();
ReteDumper.dumpRete(kieSession);
kieSession.addEventListener(new DebugAgendaEventListener());
kieSession.insert(new TestObject(1));
assertEquals(2, kieSession.fireAllRules() );
}
{code}
Resulting in the following wrong:
{code:java}
[EntryPointNode(1) EntryPoint::DEFAULT ] on Partition(MAIN)
[ObjectTypeNode(3)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.compiler.integrationtests.Misc2Test$TestObject] expiration=-1ms ] on Partition(MAIN)
[AlphaNode(10) constraint=value == 1] on Partition(3)
[LeftInputAdapterNode(11)] on Partition(3)
[RuleTerminalNode(12): rule=fileArule1] on Partition(3)
[AlphaNode(4) constraint=value == TestStaticUtils.return1()] on Partition(1)
[LeftInputAdapterNode(5)] on Partition(1)
[RuleTerminalNode(6): rule=fileBrule1] on Partition(1)
[AlphaNode(7) constraint=value == 0] on Partition(2)
[LeftInputAdapterNode(8)] on Partition(2)
[RuleTerminalNode(9): rule=fileBrule2] on Partition(2)
[ObjectTypeNode(2)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.core.reteoo.InitialFactImpl] expiration=-1ms ] on Partition(MAIN)
{code}
As AlphaNode4 should not exist, it should have been attached-merged inside AlphaNode10.
was (Author: tari_manga):
Following test when placed in Misc2Test exhibit the problem:
{code:java}
public static class TestStaticUtils {
public static int return1() {
return 1;
}
}
@Test
public void testShouldAlphaShareBecauseSameConstantDespiteDifferentSyntax() {
String drl1 = "package c;\n" +
"import " + TestObject.class.getCanonicalName() + "\n" +
"rule fileArule1 when\n" +
" TestObject(value == 1)\n" +
"then\n" +
"end\n" +
"";
String drl2 = "package iTzXzx;\n" + // <<- keep the different package
"import " + TestObject.class.getCanonicalName() + "\n" +
"import " + TestStaticUtils.class.getCanonicalName() + "\n" +
"rule fileBrule1 when\n" +
" TestObject(value == TestStaticUtils.return1() )\n" +
"then\n" +
"end\n" +
"rule fileBrule2 when\n" + // <<- keep this rule
" TestObject(value == 0 )\n" +
"then\n" +
"end\n" +
"";
KieSession kieSession = new KieHelper()
.addContent(drl1, ResourceType.DRL)
.addContent(drl2, ResourceType.DRL)
.build().newKieSession();
ReteDumper.dumpRete(kieSession);
kieSession.addEventListener(new DebugAgendaEventListener());
kieSession.insert(new TestObject(1));
assertEquals(2, kieSession.fireAllRules() );
}
{code}
Resulting in the following wrong mesh:
{code:java}
[EntryPointNode(1) EntryPoint::DEFAULT ] on Partition(MAIN)
[ObjectTypeNode(3)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.compiler.integrationtests.Misc2Test$TestObject] expiration=-1ms ] on Partition(MAIN)
[AlphaNode(10) constraint=value == 1] on Partition(3)
[LeftInputAdapterNode(11)] on Partition(3)
[RuleTerminalNode(12): rule=fileArule1] on Partition(3)
[AlphaNode(4) constraint=value == TestStaticUtils.return1()] on Partition(1)
[LeftInputAdapterNode(5)] on Partition(1)
[RuleTerminalNode(6): rule=fileBrule1] on Partition(1)
[AlphaNode(7) constraint=value == 0] on Partition(2)
[LeftInputAdapterNode(8)] on Partition(2)
[RuleTerminalNode(9): rule=fileBrule2] on Partition(2)
[ObjectTypeNode(2)::EntryPoint::DEFAULT objectType=[ClassObjectType class=org.drools.core.reteoo.InitialFactImpl] expiration=-1ms ] on Partition(MAIN)
{code}
As AlphaNode4 should not exist, it should have been attached-merged inside AlphaNode10.
> Alpha node not shared with static function evaluation
> -----------------------------------------------------
>
> Key: DROOLS-1404
> URL: https://issues.jboss.org/browse/DROOLS-1404
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Reporter: Matteo Mortari
> Assignee: Matteo Mortari
>
> The following code when placed in Misc2Test exhibit the problem
> {code:java}
> public static class TestStaticUtils {
> public static int return1() {
> return 1;
> }
> }
>
> @Test
> public void testCheck2() {
> String drl = "package c;\n" + // <<- keep this package name
> "\n" +
> "import " + TestObject.class.getCanonicalName() + "\n" +
> "\n" +
> "rule fileBrule1 when\n" +
> " TestObject(value == 1)\n" +
> "then\n" +
> "end"
> ;
>
> String drl2 = "package iTransiberian;\n" + // <<- keep this package name
> "\n" +
> "import " + TestObject.class.getCanonicalName() + "\n" +
> "import " + TestStaticUtils.class.getCanonicalName() + "\n" +
> "\n" +
> "rule fileArule1 when\n" +
> " $t : String()\n" +
> " TestObject(value == TestStaticUtils.return1() )\n" +
> "then\n" +
> "end\n"+
> "rule fileArule2 when\n" + // <<- keep this rule
> " $t : String()\n" +
> " TestObject(value == 0 )\n" +
> "then\n" +
> "end\n" +
> ""
> ;
> KieSession kieSession = new KieHelper()
> .addContent(drl2, ResourceType.DRL)
> .addContent(drl, ResourceType.DRL)
> .build().newKieSession();
>
> ReteDumper.dumpRete(kieSession);
> System.out.println(drl);
> System.out.println(drl2);
> kieSession.addEventListener(new DebugAgendaEventListener());
> kieSession.insert("test");
> kieSession.insert(new TestObject(1));
> assertEquals(2, kieSession.fireAllRules() );
> }
> {code}
> Conducting further analysis...
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)
More information about the jboss-jira
mailing list