From 6f5b24aff223ff5ff4670e88312689841f55c9c0 Mon Sep 17 00:00:00 2001 From: mariofusco Date: Thu, 12 Dec 2024 19:13:51 +0100 Subject: [PATCH] wip --- .../core/phreak/EagerPhreakBuilder.java | 23 ++----------- .../AddRemoveGenerated2RulesNotNotTest.java | 1 - .../AddRemoveGenerated2RulesNotTest.java | 1 - .../CasesFromGeneratedRulesTest.java | 32 +++++++++++++++++++ 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java b/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java index 2c4e58d806f..15478b1a2b7 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java +++ b/drools-core/src/main/java/org/drools/core/phreak/EagerPhreakBuilder.java @@ -151,8 +151,6 @@ public void removeRule(TerminalNode tn, Collection wms, I } } - Set smemsToNotify = new HashSet<>(); - if (exclBranchRoots.isEmpty()) { LeftTupleNode lian = tn.getPathNodes()[0]; processLeftTuples(lian, false, tn, wms); @@ -163,7 +161,7 @@ public void removeRule(TerminalNode tn, Collection wms, I // Process existing branches from the split points Set visited = new HashSet<>(); - exclBranchRoots.forEach(pair -> Remove.processMerges(pair.parent, tn, kBase, wms, visited, smemsToNotify)); + exclBranchRoots.forEach(pair -> Remove.processMerges(pair.parent, tn, kBase, wms, visited)); } for (InternalWorkingMemory wm : wms) { @@ -174,8 +172,6 @@ public void removeRule(TerminalNode tn, Collection wms, I pmem.getRuleAgendaItem().dequeue(); } } - - smemsToNotify.forEach(pair -> pair.sm.notifyRuleLinkSegment(pair.wm)); } public static void notifyImpactedSegments(SegmentMemory smem, InternalWorkingMemory wm, Set segmentsToNotify) { @@ -736,8 +732,7 @@ private static void removeExistingPaths(List exclBranchRoots, TerminalNode } } - - private static void processMerges(LeftTupleNode splitNode, TerminalNode tn, InternalRuleBase kBase, Collection wms, Set visited, Set smemsToNotify) { + private static void processMerges(LeftTupleNode splitNode, TerminalNode tn, InternalRuleBase kBase, Collection wms, Set visited) { // it's possible for a rule to have multiple exclBranches, pointing to the same parent. So need to ensure it's processed once. if ( !visited.add(splitNode.getId())) { return; @@ -766,10 +761,7 @@ private static void processMerges(LeftTupleNode splitNode, TerminalNode tn, Inte } SegmentPrototype proto2 = kBase.getSegmentPrototype(ltn); - mergeSegments(proto1, proto2, kBase, wms); - - notifyImpactedSegments(wms, proto1, smemsToNotify); } } @@ -1443,17 +1435,6 @@ private static void updatePaths(SegmentPrototype proto, Collection wms, SegmentPrototype proto1, Set smemsToNotify) { - // any impacted segments must be notified for potential linking - for (InternalWorkingMemory wm : wms) { - Memory mem1 = wm.getNodeMemories().peekNodeMemory(proto1.getRootNode()); - if (mem1 != null && mem1.getSegmentMemory() != null) { - // there was a split segment, both need notifying. - notifyImpactedSegments(mem1.getSegmentMemory(), wm, smemsToNotify); - } - } - } - private static void setNodeTypes(SegmentPrototype proto, LeftTupleNode[] protoNodes) { int nodeTypesInSegment = 0; for ( LeftTupleNode node : protoNodes) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java index 77fae44b931..161c91cd728 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotNotTest.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Disabled; -@Disabled("It gets stuck. See issue #6190") public class AddRemoveGenerated2RulesNotNotTest extends AbstractAddRemoveGenerated2RulesTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java index 8e8a40e7595..e83554563b4 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/AddRemoveGenerated2RulesNotTest.java @@ -22,7 +22,6 @@ import org.junit.jupiter.api.Disabled; -@Disabled("It gets stuck. See issue #6190") public class AddRemoveGenerated2RulesNotTest extends AbstractAddRemoveGenerated2RulesTest { public static Stream parameters() { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/CasesFromGeneratedRulesTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/CasesFromGeneratedRulesTest.java index 2462e2165ad..13696bba1a3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/CasesFromGeneratedRulesTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/incrementalcompilation/CasesFromGeneratedRulesTest.java @@ -52,4 +52,36 @@ public void testInsertFactsFireRulesRemoveRulesReinsertRulesRevertedRules() { AddRemoveTestCases.insertFactsFireRulesRemoveRulesReinsertRules1(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, 1, 2); } + + @Test + @Timeout(40000) + public void testInsertFactsRemoveRulesFireRulesRemoveRules() { + String rule1 = """ + package com.rules; + global java.util.List list + rule R1 + when + exists(Integer()) + not(Double() and Double()) + Integer() not(Double() and Double()) + then + list.add('R1'); + end + """; + + String rule2 = """ + package com.rules; + global java.util.List list + rule R2 + when + exists(Integer()) + not(Double() and Double()) + exists(Integer()) + then + list.add('R2'); + end + """; + + AddRemoveTestCases.insertFactsRemoveRulesFireRulesRemoveRules2(rule1, rule2, TestUtil.RULE1_NAME, TestUtil.RULE2_NAME, null, 1); + } }