From 41ac5c9bf3bf8cc42c134a6671f0dcf42f81a436 Mon Sep 17 00:00:00 2001 From: mariofusco Date: Tue, 16 Jan 2024 17:34:39 +0100 Subject: [PATCH] minor semplifications --- .../core/base/AbstractQueryViewListener.java | 4 +- .../core/common/EmptyBetaConstraints.java | 9 +- .../drools/core/common/SuperCacheFixer.java | 147 +++----------- .../core/phreak/EagerPhreakBuilder.java | 19 +- .../drools/core/phreak/LazyPhreakBuilder.java | 23 ++- .../core/phreak/PhreakAccumulateNode.java | 3 +- .../drools/core/phreak/PhreakExistsNode.java | 5 +- .../drools/core/phreak/PhreakJoinNode.java | 3 +- .../org/drools/core/phreak/PhreakNotNode.java | 9 +- .../phreak/PhreakSubnetworkNotExistsNode.java | 4 +- .../core/phreak/RuleNetworkEvaluator.java | 19 +- .../drools/core/phreak/SegmentPropagator.java | 4 +- .../drools/core/reteoo/AccumulateNode.java | 14 +- .../org/drools/core/reteoo/AsyncSendNode.java | 12 +- .../org/drools/core/reteoo/BetaMemory.java | 156 ++++++++++++++- .../drools/core/reteoo/BetaMemoryImpl.java | 181 ------------------ .../java/org/drools/core/reteoo/BetaNode.java | 16 +- .../org/drools/core/reteoo/ExistsNode.java | 3 +- .../java/org/drools/core/reteoo/FromNode.java | 14 +- .../java/org/drools/core/reteoo/JoinNode.java | 3 +- .../java/org/drools/core/reteoo/NotNode.java | 6 +- .../drools/core/reteoo/ReactiveFromNode.java | 12 +- .../org/drools/core/reteoo/SegmentMemory.java | 8 +- .../core/reteoo/SingleObjectSinkAdapter.java | 8 +- .../drools/core/util/index/IndexFactory.java | 20 +- .../drools/core/reteoo/ReteMemoryChecker.java | 2 +- .../core/positional/PositionalConstraint.java | 17 +- .../kiesession/NodeSegmentUnlinkingTest.java | 68 +++---- .../drools/kiesession/RuleUnlinkingTest.java | 16 +- .../RuleUnlinkingWithSegmentMemoryTest.java | 26 +-- .../metric/phreak/PhreakExistsNodeMetric.java | 5 +- .../metric/phreak/PhreakJoinNodeMetric.java | 5 +- .../metric/phreak/PhreakNotNodeMetric.java | 5 +- .../drools/mvel/compiler/MemoryLeakTest.java | 3 +- .../mvel/integrationtests/LinkingTest.java | 41 ++-- .../PhreakConcurrencyTest.java | 4 +- .../integrationtests/SegmentCreationTest.java | 12 +- .../integrationtests/phreak/AddRuleTest.java | 12 +- .../phreak/PhreakJoinNodeTest.java | 12 +- .../phreak/PhreakNotNodeTest.java | 10 +- .../phreak/RemoveRuleTest.java | 15 +- .../integrationtests/phreak/Scenario.java | 5 +- .../integrationtests/phreak/ScenarioTest.java | 12 +- .../phreak/SegmentPropagationTest.java | 20 +- 44 files changed, 416 insertions(+), 576 deletions(-) delete mode 100644 drools-core/src/main/java/org/drools/core/reteoo/BetaMemoryImpl.java diff --git a/drools-core/src/main/java/org/drools/core/base/AbstractQueryViewListener.java b/drools-core/src/main/java/org/drools/core/base/AbstractQueryViewListener.java index 2d778fe4c4d..5b4da5779b8 100644 --- a/drools-core/src/main/java/org/drools/core/base/AbstractQueryViewListener.java +++ b/drools-core/src/main/java/org/drools/core/base/AbstractQueryViewListener.java @@ -22,10 +22,8 @@ import java.util.List; import org.drools.base.definitions.rule.impl.RuleImpl; -import org.drools.core.common.BaseNode; import org.drools.core.common.ReteEvaluator; import org.drools.core.common.SuperCacheFixer; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.QueryTerminalNode; import org.drools.core.reteoo.TupleImpl; import org.kie.api.runtime.rule.FactHandle; @@ -46,7 +44,7 @@ public List getResults() { public void rowAdded(RuleImpl rule, TupleImpl tuple, ReteEvaluator reteEvaluator) { FactHandle[] handles = new FactHandle[SuperCacheFixer.getLeftTupleNode(tuple).getObjectCount()]; - TupleImpl entry = (LeftTuple) tuple.skipEmptyHandles(); + TupleImpl entry = tuple.skipEmptyHandles(); // Add all the FactHandles int i = handles.length-1; diff --git a/drools-core/src/main/java/org/drools/core/common/EmptyBetaConstraints.java b/drools-core/src/main/java/org/drools/core/common/EmptyBetaConstraints.java index 318a6a60784..b129c99faad 100644 --- a/drools-core/src/main/java/org/drools/core/common/EmptyBetaConstraints.java +++ b/drools-core/src/main/java/org/drools/core/common/EmptyBetaConstraints.java @@ -31,7 +31,6 @@ import org.drools.base.rule.constraint.BetaConstraint; import org.drools.core.RuleBaseConfiguration; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.Tuple; import org.drools.core.reteoo.builder.BuildContext; import org.drools.core.util.index.TupleList; @@ -117,10 +116,10 @@ public boolean isEmpty() { public BetaMemory createBetaMemory(final RuleBaseConfiguration config, final int nodeType) { - return new BetaMemoryImpl(config.isSequential() ? null : new TupleList(), - new TupleList(), - EMPTY, - nodeType ); + return new BetaMemory(config.isSequential() ? null : new TupleList(), + new TupleList(), + EMPTY, + nodeType ); } public int hashCode() { diff --git a/drools-core/src/main/java/org/drools/core/common/SuperCacheFixer.java b/drools-core/src/main/java/org/drools/core/common/SuperCacheFixer.java index 6ca91a3c515..c98789a52ec 100644 --- a/drools-core/src/main/java/org/drools/core/common/SuperCacheFixer.java +++ b/drools-core/src/main/java/org/drools/core/common/SuperCacheFixer.java @@ -21,7 +21,6 @@ import org.drools.base.common.NetworkNode; import org.drools.base.reteoo.NodeTypeEnums; import org.drools.core.reteoo.AccumulateNode; -import org.drools.core.reteoo.AlphaNode; import org.drools.core.reteoo.AlphaTerminalNode; import org.drools.core.reteoo.AsyncReceiveNode; import org.drools.core.reteoo.AsyncSendNode; @@ -35,8 +34,6 @@ import org.drools.core.reteoo.LeftTupleSinkNode; import org.drools.core.reteoo.LeftTupleSource; import org.drools.core.reteoo.NotNode; -import org.drools.core.reteoo.ObjectSource; -import org.drools.core.reteoo.ObjectTypeNode; import org.drools.core.reteoo.ObjectTypeNodeId; import org.drools.core.reteoo.QueryElementNode; import org.drools.core.reteoo.QueryTerminalNode; @@ -54,9 +51,10 @@ // It's better to always cast to a concrete or abstract class to avoid // secondary super cache problem. See https://issues.redhat.com/browse/DROOLS-7521 public class SuperCacheFixer { + public static LeftTupleNode getLeftTupleNode(TupleImpl t) { Sink s = t.getSink(); - switch (((BaseNode) s).getType()) { + switch (s.getType()) { case NodeTypeEnums.RuleTerminalNode : return (RuleTerminalNode) s; case NodeTypeEnums.QueryTerminalNode: return (QueryTerminalNode) s; case NodeTypeEnums.RightInputAdapterNode: return (RightInputAdapterNode) s; @@ -82,7 +80,7 @@ public static LeftTupleNode getLeftTupleNode(TupleImpl t) { public static RightTupleSink getRightTupleSink(RightTuple t) { Sink s = t.getSink(); - switch (((BaseNode) s).getType()) { + switch (s.getType()) { case NodeTypeEnums.AccumulateNode : return (AccumulateNode) s; case NodeTypeEnums.ExistsNode: return (ExistsNode) s; case NodeTypeEnums.NotNode: return (NotNode) s; @@ -96,7 +94,7 @@ public static RightTupleSink getRightTupleSink(RightTuple t) { } public static LeftTupleSinkNode asLeftTupleSink(NetworkNode n) { - switch (((BaseNode) n).getType()) { + switch (n.getType()) { case NodeTypeEnums.RuleTerminalNode : return (RuleTerminalNode) n; case NodeTypeEnums.QueryTerminalNode: return (QueryTerminalNode) n; case NodeTypeEnums.RightInputAdapterNode: return (RightInputAdapterNode) n; @@ -118,56 +116,9 @@ public static LeftTupleSinkNode asLeftTupleSink(NetworkNode n) { } } - public static NetworkNode checkcast(NetworkNode n) { - switch (((BaseNode)n).getType()) { - case NodeTypeEnums.ObjectTypeNode : return (ObjectTypeNode) n; - case NodeTypeEnums.AlphaNode : return (AlphaNode) n; - case NodeTypeEnums.LeftInputAdapterNode: return (LeftInputAdapterNode) n; - case NodeTypeEnums.AlphaTerminalNode: return (AlphaTerminalNode) n; - case NodeTypeEnums.RuleTerminalNode : return (RuleTerminalNode) n; - case NodeTypeEnums.QueryTerminalNode: return (QueryTerminalNode) n; - case NodeTypeEnums.RightInputAdapterNode: return (RightInputAdapterNode) n; - case NodeTypeEnums.AccumulateNode : return (AccumulateNode) n; - case NodeTypeEnums.ExistsNode: return (ExistsNode) n; - case NodeTypeEnums.NotNode: return (NotNode) n; - case NodeTypeEnums.FromNode: return (FromNode) n; - case NodeTypeEnums.JoinNode: return (JoinNode) n; - case NodeTypeEnums.EvalConditionNode: return (EvalConditionNode) n; - case NodeTypeEnums.AsyncReceiveNode: return (AsyncReceiveNode) n; - case NodeTypeEnums.AsyncSendNode: return (AsyncSendNode) n; - case NodeTypeEnums.ReactiveFromNode: return (ReactiveFromNode) n; - case NodeTypeEnums.ConditionalBranchNode: return (ConditionalBranchNode) n; - case NodeTypeEnums.QueryElementNode: return (QueryElementNode) n; - case NodeTypeEnums.WindowNode: return (WindowNode) n; - case NodeTypeEnums.TimerConditionNode: return (TimerNode) n; - case NodeTypeEnums.MockBetaNode: return (NetworkNode) n; - case NodeTypeEnums.MockAlphaNode: return (NetworkNode) n; - default: - throw new UnsupportedOperationException("Switch needs to include: " + n); - } - } - - public static NetworkNode getSink(TupleImpl t) { - return checkcast(t.getSink()); - } - - public static ObjectTypeNode getObjectTypeNode(TupleImpl t) { - Sink s = t.getSink(); - switch (((BaseNode) s).getType()) { - case NodeTypeEnums.RuleTerminalNode : return ((RuleTerminalNode) s).getObjectTypeNode(); - case NodeTypeEnums.QueryTerminalNode: return ((QueryTerminalNode) s).getObjectTypeNode(); - case NodeTypeEnums.AccumulateNode : return ((AccumulateNode) s).getObjectTypeNode(); - case NodeTypeEnums.ExistsNode: return ((ExistsNode) s).getObjectTypeNode(); - case NodeTypeEnums.NotNode: return ((NotNode) s).getObjectTypeNode(); - case NodeTypeEnums.JoinNode: return ((JoinNode) s).getObjectTypeNode(); - default: - throw new UnsupportedOperationException("Node does not have an ObjectType: " + s); - } - } - public static ObjectTypeNodeId getLeftInputOtnId(TupleImpl t) { Sink s = t.getSink(); - switch (((BaseNode) s).getType()) { + switch (s.getType()) { case NodeTypeEnums.RuleTerminalNode : return ((RuleTerminalNode) s).getLeftInputOtnId(); case NodeTypeEnums.QueryTerminalNode: return ((QueryTerminalNode) s).getLeftInputOtnId(); case NodeTypeEnums.RightInputAdapterNode: return ((RightInputAdapterNode) s).getLeftInputOtnId(); @@ -191,7 +142,7 @@ public static ObjectTypeNodeId getLeftInputOtnId(TupleImpl t) { public static ObjectTypeNodeId getRightInputOtnId(TupleImpl t) { Sink s = t.getSink(); - switch (((BaseNode) s).getType()) { + switch (s.getType()) { case NodeTypeEnums.AccumulateNode : return ((AccumulateNode) s).getRightInputOtnId(); case NodeTypeEnums.ExistsNode: return ((ExistsNode) s).getRightInputOtnId(); case NodeTypeEnums.NotNode: return ((NotNode) s).getRightInputOtnId(); @@ -204,85 +155,33 @@ public static ObjectTypeNodeId getRightInputOtnId(TupleImpl t) { public static LeftTupleSource getLeftTupleSource(TupleImpl t) { Sink s = t.getSink(); - LeftTupleSource n; - switch (((BaseNode) s).getType()) { - case NodeTypeEnums.RuleTerminalNode : n = ((RuleTerminalNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.QueryTerminalNode: n = ((QueryTerminalNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.RightInputAdapterNode: n = ((RightInputAdapterNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.AccumulateNode : n = ((AccumulateNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.ExistsNode: n = ((ExistsNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.NotNode: n = ((NotNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.JoinNode: n = ((JoinNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.FromNode: n = ((FromNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.EvalConditionNode: n = ((EvalConditionNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.AsyncReceiveNode: n = ((AsyncReceiveNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.AsyncSendNode: n = ((AsyncSendNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.ReactiveFromNode: n = ((ReactiveFromNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.ConditionalBranchNode: n = ((ConditionalBranchNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.QueryElementNode: n = ((QueryElementNode) s).getLeftTupleSource(); break; - case NodeTypeEnums.TimerConditionNode: n = ((TimerNode) s).getLeftTupleSource(); break; + switch (s.getType()) { + case NodeTypeEnums.RuleTerminalNode : return ((RuleTerminalNode) s).getLeftTupleSource(); + case NodeTypeEnums.QueryTerminalNode: return ((QueryTerminalNode) s).getLeftTupleSource(); + case NodeTypeEnums.RightInputAdapterNode: return ((RightInputAdapterNode) s).getLeftTupleSource(); + case NodeTypeEnums.AccumulateNode : return ((AccumulateNode) s).getLeftTupleSource(); + case NodeTypeEnums.ExistsNode: return ((ExistsNode) s).getLeftTupleSource(); + case NodeTypeEnums.NotNode: return ((NotNode) s).getLeftTupleSource(); + case NodeTypeEnums.JoinNode: return ((JoinNode) s).getLeftTupleSource(); + case NodeTypeEnums.FromNode: return ((FromNode) s).getLeftTupleSource(); + case NodeTypeEnums.EvalConditionNode: return ((EvalConditionNode) s).getLeftTupleSource(); + case NodeTypeEnums.AsyncReceiveNode: return ((AsyncReceiveNode) s).getLeftTupleSource(); + case NodeTypeEnums.AsyncSendNode: return ((AsyncSendNode) s).getLeftTupleSource(); + case NodeTypeEnums.ReactiveFromNode: return ((ReactiveFromNode) s).getLeftTupleSource(); + case NodeTypeEnums.ConditionalBranchNode: return ((ConditionalBranchNode) s).getLeftTupleSource(); + case NodeTypeEnums.QueryElementNode: return ((QueryElementNode) s).getLeftTupleSource(); + case NodeTypeEnums.TimerConditionNode: return ((TimerNode) s).getLeftTupleSource(); default: throw new UnsupportedOperationException("Does not have a LeftTupleSource: " + s); } - - switch (n.getType()) { - case NodeTypeEnums.LeftInputAdapterNode: return (LeftInputAdapterNode) n; - case NodeTypeEnums.AlphaTerminalNode: return (AlphaTerminalNode) n; - case NodeTypeEnums.AccumulateNode : return (AccumulateNode) n; - case NodeTypeEnums.ExistsNode: return (ExistsNode) n; - case NodeTypeEnums.NotNode: return (NotNode) n; - case NodeTypeEnums.FromNode: return (FromNode) n; - case NodeTypeEnums.JoinNode: return (JoinNode) n; - case NodeTypeEnums.EvalConditionNode: return (EvalConditionNode) n; - case NodeTypeEnums.AsyncReceiveNode: return (AsyncReceiveNode) n; - case NodeTypeEnums.AsyncSendNode: return (AsyncSendNode) n; - case NodeTypeEnums.ReactiveFromNode: return (ReactiveFromNode) n; - case NodeTypeEnums.ConditionalBranchNode: return (ConditionalBranchNode) n; - case NodeTypeEnums.QueryElementNode: return (QueryElementNode) n; - case NodeTypeEnums.TimerConditionNode: return (TimerNode) n; - default: - throw new UnsupportedOperationException("Switch needs to include: " + n); - } - } - - public static ObjectSource getObjectSource(TupleImpl t) { - Sink s = t.getSink(); - ObjectSource o; - switch (((BaseNode) s).getType()) { - case NodeTypeEnums.AccumulateNode : o = ((AccumulateNode) s).getRightInput(); break; - case NodeTypeEnums.ExistsNode: o = ((ExistsNode) s).getRightInput(); break; - case NodeTypeEnums.NotNode: o = ((NotNode) s).getRightInput(); break; - case NodeTypeEnums.JoinNode: o = ((JoinNode) s).getRightInput(); break; - default: - throw new UnsupportedOperationException("Node does not have an ObjectSource: " + s); - } - - switch (o.getType()) { - case NodeTypeEnums.AlphaNode : return (AlphaNode) o; - case NodeTypeEnums.WindowNode: return (WindowNode) o; - case NodeTypeEnums.ObjectTypeNode : return (ObjectTypeNode) o; - case NodeTypeEnums.RightInputAdapterNode : return (RightInputAdapterNode) o; - default: - throw new UnsupportedOperationException("Node does match an ObjectSource: " + o); - } } public static TerminalNode asTerminalNode(TupleImpl t) { Sink s = t.getSink(); - switch (((BaseNode) t.getSink()).getType()) { + switch (t.getSink().getType()) { case NodeTypeEnums.RuleTerminalNode : return (RuleTerminalNode) s; case NodeTypeEnums.QueryTerminalNode: return (QueryTerminalNode) s; default: return null; } } - - public static TerminalNode asTerminalNode(NetworkNode n) { - switch (((BaseNode)n).getType()) { - case NodeTypeEnums.RuleTerminalNode : return (RuleTerminalNode) n; - case NodeTypeEnums.QueryTerminalNode: return (QueryTerminalNode) n; - default: return null; - } - - - } } 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 22127713f2e..e53afd9935b 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 @@ -45,7 +45,6 @@ import org.drools.core.reteoo.AccumulateNode.AccumulateMemory; import org.drools.core.reteoo.AlphaTerminalNode; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.BetaNode; import org.drools.core.reteoo.FromNode.FromMemory; import org.drools.core.reteoo.LeftInputAdapterNode; @@ -956,11 +955,11 @@ private static void mergeEagerProtos(SegmentPrototype proto1, SegmentPrototype p private static void deleteRightInputData(LeftTupleNode node, Memory m, InternalWorkingMemory wm) { BetaNode bn = (BetaNode) node; - BetaMemoryImpl bm; + BetaMemory bm; if (bn.getType() == NodeTypeEnums.AccumulateNode) { bm = ((AccumulateMemory) m).getBetaMemory(); } else { - bm = (BetaMemoryImpl) m; + bm = (BetaMemory) m; } TupleMemory rtm = bm.getRightTupleMemory(); @@ -1159,25 +1158,25 @@ private static void visitChild(InternalWorkingMemory wm, boolean insert, Termina private static void visitChild(TupleImpl lt, boolean insert, InternalWorkingMemory wm, TerminalNode tn) { TupleImpl prevLt = null; - LeftTupleSinkNode sink = (LeftTupleSinkNode) SuperCacheFixer.getSink(lt); + LeftTupleSinkNode sink = (LeftTupleSinkNode) lt.getSink(); for ( ; sink != null; sink = sink.getNextLeftTupleSinkNode() ) { if ( lt != null ) { - if (isAssociatedWith(SuperCacheFixer.getSink(lt), tn)) { + if (isAssociatedWith(lt.getSink(), tn)) { - if (SuperCacheFixer.getSink(lt).getAssociatedTerminalsSize() > 1) { + if (lt.getSink().getAssociatedTerminalsSize() > 1) { if (lt.getFirstChild() != null) { for ( TupleImpl child = lt.getFirstChild(); child != null; child = child.getHandleNext() ) { visitChild(child, insert, wm, tn); } - } else if (SuperCacheFixer.getSink(lt).getType() == NodeTypeEnums.RightInputAdapterNode) { + } else if (lt.getSink().getType() == NodeTypeEnums.RightInputAdapterNode) { insertPeerRightTuple(lt, wm, tn, insert); } } else if (!insert) { iterateLeftTuple( lt, wm ); TupleImpl lt2 = null; for ( TupleImpl peerLt = lt.getPeer(); - peerLt != null && isAssociatedWith(SuperCacheFixer.getSink(peerLt), tn) && peerLt.getSink().getAssociatedTerminalsSize() == 1; + peerLt != null && isAssociatedWith(peerLt.getSink(), tn) && peerLt.getSink().getAssociatedTerminalsSize() == 1; peerLt = peerLt.getPeer() ) { iterateLeftTuple( peerLt, wm ); lt2 = peerLt; @@ -1201,7 +1200,7 @@ private static void visitChild(TupleImpl lt, boolean insert, InternalWorkingMemo private static void insertPeerRightTuple(TupleImpl lt, InternalWorkingMemory wm, TerminalNode tn, boolean insert ) { // There's a shared RightInputAdapterNode, so check if one of its sinks is associated only to the new rule TupleImpl prevLt = null; - RightInputAdapterNode rian = (RightInputAdapterNode) SuperCacheFixer.getSink(lt); + RightInputAdapterNode rian = (RightInputAdapterNode) lt.getSink(); for (ObjectSink sink : rian.getObjectSinkPropagator().getSinks()) { if (lt != null) { @@ -1211,7 +1210,7 @@ private static void insertPeerRightTuple(TupleImpl lt, InternalWorkingMemory wm, prevLt = lt; lt = lt.getPeer(); } else if (insert) { - BetaMemoryImpl bm = (BetaMemoryImpl) wm.getNodeMemories().peekNodeMemory(sink); + BetaMemory bm = (BetaMemory) wm.getNodeMemories().peekNodeMemory(sink); if (bm != null) { prevLt = TupleFactory.createPeer(rian, prevLt); bm.linkNode((BetaNode) sink, wm); diff --git a/drools-core/src/main/java/org/drools/core/phreak/LazyPhreakBuilder.java b/drools-core/src/main/java/org/drools/core/phreak/LazyPhreakBuilder.java index 9aeb1c59250..bc527959b7c 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/LazyPhreakBuilder.java +++ b/drools-core/src/main/java/org/drools/core/phreak/LazyPhreakBuilder.java @@ -50,7 +50,6 @@ import org.drools.core.reteoo.AsyncReceiveNode; import org.drools.core.reteoo.AsyncSendNode; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.BetaNode; import org.drools.core.reteoo.ConditionalBranchNode; import org.drools.core.reteoo.EvalConditionNode; @@ -744,11 +743,11 @@ private static void insertFacts(PathEndNodes endNodes, Collection 1) { + if (lt.getSink().getAssociatedTerminalsSize() > 1) { if (lt.getFirstChild() != null) { for ( TupleImpl child = lt.getFirstChild(); child != null; child = child.getHandleNext() ) { visitChild(child, insert, wm, rule); } - } else if (SuperCacheFixer.getSink(lt).getType() == NodeTypeEnums.RightInputAdapterNode) { + } else if (lt.getSink().getType() == NodeTypeEnums.RightInputAdapterNode) { insertPeerRightTuple(lt, wm, rule, insert); } } else if (!insert) { iterateLeftTuple( lt, wm ); TupleImpl lt2 = null; for ( TupleImpl peerLt = lt.getPeer(); - peerLt != null && SuperCacheFixer.getSink(peerLt).isAssociatedWith(rule) && peerLt.getSink().getAssociatedTerminalsSize() == 1; + peerLt != null && peerLt.getSink().isAssociatedWith(rule) && peerLt.getSink().getAssociatedTerminalsSize() == 1; peerLt = peerLt.getPeer() ) { iterateLeftTuple( peerLt, wm ); lt2 = peerLt; @@ -953,7 +952,7 @@ private static void visitChild(TupleImpl lt, boolean insert, InternalWorkingMemo private static void insertPeerRightTuple( TupleImpl lt, InternalWorkingMemory wm, Rule rule, boolean insert ) { // There's a shared RightInputAdaterNode, so check if one of its sinks is associated only to the new rule TupleImpl prevLt = null; - RightInputAdapterNode rian = (RightInputAdapterNode) SuperCacheFixer.getSink(lt); + RightInputAdapterNode rian = (RightInputAdapterNode) lt.getSink(); for (ObjectSink sink : rian.getObjectSinkPropagator().getSinks()) { if (lt != null) { @@ -963,7 +962,7 @@ private static void insertPeerRightTuple( TupleImpl lt, InternalWorkingMemory wm prevLt = lt; lt = lt.getPeer(); } else if (insert) { - BetaMemoryImpl bm = (BetaMemoryImpl) wm.getNodeMemory((BetaNode) sink); + BetaMemory bm = (BetaMemory) wm.getNodeMemory((BetaNode) sink); prevLt = TupleFactory.createPeer(rian, prevLt); bm.linkNode( (BetaNode) sink, wm ); bm.getStagedRightTuples().addInsert(prevLt); @@ -1564,7 +1563,7 @@ private static long processLiaNode(LeftInputAdapterNode tupleSource, ReteEvaluat } private static long processBetaNode(BetaNode betaNode, ReteEvaluator reteEvaluator, SegmentMemory smem, List memories, long nodePosMask, long allLinkedTestMask, boolean updateNodeBit) { - BetaMemoryImpl bm; + BetaMemory bm; if (NodeTypeEnums.AccumulateNode == betaNode.getType()) { AccumulateNode.AccumulateMemory accMemory = ((AccumulateNode.AccumulateMemory) smem.createNodeMemory(betaNode, reteEvaluator)); memories.add(accMemory); @@ -1572,7 +1571,7 @@ private static long processBetaNode(BetaNode betaNode, ReteEvaluator reteEvaluat bm = accMemory.getBetaMemory(); } else { - bm = (BetaMemoryImpl) smem.createNodeMemory(betaNode, reteEvaluator); + bm = (BetaMemory) smem.createNodeMemory(betaNode, reteEvaluator); memories.add(bm); } diff --git a/drools-core/src/main/java/org/drools/core/phreak/PhreakAccumulateNode.java b/drools-core/src/main/java/org/drools/core/phreak/PhreakAccumulateNode.java index 71fc226c648..33e72c91ec7 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/PhreakAccumulateNode.java +++ b/drools-core/src/main/java/org/drools/core/phreak/PhreakAccumulateNode.java @@ -33,7 +33,6 @@ import org.drools.core.reteoo.AccumulateNode.AccumulateMemory; import org.drools.core.reteoo.AccumulateNode.BaseAccumulation; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; import org.drools.core.reteoo.RightTuple; @@ -56,7 +55,7 @@ public void doNode(AccumulateNode accNode, TupleSets trgLeftTuples, TupleSets stagedLeftTuples) { - BetaMemoryImpl bm = am.getBetaMemory(); + BetaMemory bm = am.getBetaMemory(); TupleSets srcRightTuples = bm.getStagedRightTuples().takeAll(); diff --git a/drools-core/src/main/java/org/drools/core/phreak/PhreakExistsNode.java b/drools-core/src/main/java/org/drools/core/phreak/PhreakExistsNode.java index c67d792cbd5..bc66defa8e1 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/PhreakExistsNode.java +++ b/drools-core/src/main/java/org/drools/core/phreak/PhreakExistsNode.java @@ -23,7 +23,6 @@ import org.drools.core.common.ReteEvaluator; import org.drools.core.common.TupleSets; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.ExistsNode; import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; @@ -38,7 +37,7 @@ public class PhreakExistsNode { public void doNode(ExistsNode existsNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, @@ -53,7 +52,7 @@ public void doNode(ExistsNode existsNode, public void doNormalNode(ExistsNode existsNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, diff --git a/drools-core/src/main/java/org/drools/core/phreak/PhreakJoinNode.java b/drools-core/src/main/java/org/drools/core/phreak/PhreakJoinNode.java index deb94e58018..5620f393642 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/PhreakJoinNode.java +++ b/drools-core/src/main/java/org/drools/core/phreak/PhreakJoinNode.java @@ -22,7 +22,6 @@ import org.drools.core.common.ReteEvaluator; import org.drools.core.common.TupleSets; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; @@ -35,7 +34,7 @@ public class PhreakJoinNode { public void doNode(JoinNode joinNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, diff --git a/drools-core/src/main/java/org/drools/core/phreak/PhreakNotNode.java b/drools-core/src/main/java/org/drools/core/phreak/PhreakNotNode.java index 7b0b369d264..3cb56b6e013 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/PhreakNotNode.java +++ b/drools-core/src/main/java/org/drools/core/phreak/PhreakNotNode.java @@ -23,7 +23,6 @@ import org.drools.core.common.ReteEvaluator; import org.drools.core.common.TupleSets; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; import org.drools.core.reteoo.NotNode; @@ -38,7 +37,7 @@ public class PhreakNotNode { public void doNode(NotNode notNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, @@ -54,7 +53,7 @@ public void doNode(NotNode notNode, public void doNormalNode(NotNode notNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, @@ -142,7 +141,7 @@ public void doLeftInserts(NotNode notNode, } public void doRightInserts(NotNode notNode, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcRightTuples, TupleSets trgLeftTuples, @@ -207,7 +206,7 @@ public void doRightInserts(NotNode notNode, } public static void unlinkNotNodeOnRightInsert(NotNode notNode, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator) { if (bm.getSegmentMemory().isSegmentLinked() && notNode.isEmptyBetaConstraints()) { // this must be processed here, rather than initial insert, as we need to link the blocker diff --git a/drools-core/src/main/java/org/drools/core/phreak/PhreakSubnetworkNotExistsNode.java b/drools-core/src/main/java/org/drools/core/phreak/PhreakSubnetworkNotExistsNode.java index aa3261bbe7a..e9e9c849507 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/PhreakSubnetworkNotExistsNode.java +++ b/drools-core/src/main/java/org/drools/core/phreak/PhreakSubnetworkNotExistsNode.java @@ -20,7 +20,7 @@ import org.drools.base.reteoo.NodeTypeEnums; import org.drools.core.common.TupleSets; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.BetaNode; import org.drools.core.reteoo.LeftTupleSink; import org.drools.core.reteoo.SubnetworkTuple; @@ -35,7 +35,7 @@ public class PhreakSubnetworkNotExistsNode { public static void doSubNetworkNode(BetaNode node, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, TupleSets srcLeftTuples, TupleSets trgLeftTuples, TupleSets stagedLeftTuples) { diff --git a/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java b/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java index da32fb892ab..eef6b8ad1b8 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java +++ b/drools-core/src/main/java/org/drools/core/phreak/RuleNetworkEvaluator.java @@ -39,7 +39,6 @@ import org.drools.core.reteoo.AsyncSendNode; import org.drools.core.reteoo.AsyncSendNode.AsyncSendMemory; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.BetaNode; import org.drools.core.reteoo.ConditionalBranchNode; import org.drools.core.reteoo.ConditionalBranchNode.ConditionalBranchMemory; @@ -547,13 +546,13 @@ private boolean evalBetaNode(PathMemory pmem, NetworkNode node, Memory nodeMem, LinkedList stack, boolean processRian, RuleExecutor executor, TupleSets srcTuples, TupleSets stagedLeftTuples, LeftTupleSinkNode sink) { BetaNode betaNode = (BetaNode) node; - BetaMemoryImpl bm; + BetaMemory bm; AccumulateMemory am = null; if (NodeTypeEnums.AccumulateNode == node.getType()) { am = (AccumulateMemory) nodeMem; bm = am.getBetaMemory(); } else { - bm = (BetaMemoryImpl) nodeMem; + bm = (BetaMemory) nodeMem; } if (processRian && betaNode.isRightInputIsRiaNode()) { @@ -570,7 +569,7 @@ private boolean evalBetaNode(PathMemory pmem, NetworkNode node, Memory nodeMem, } private void switchOnDoBetaNode(NetworkNode node, TupleSets trgTuples, ReteEvaluator reteEvaluator, TupleSets srcTuples, - TupleSets stagedLeftTuples, LeftTupleSinkNode sink, BetaMemoryImpl bm, AccumulateMemory am) { + TupleSets stagedLeftTuples, LeftTupleSinkNode sink, BetaMemory bm, AccumulateMemory am) { if (log.isTraceEnabled()) { int offset = getOffset(node); log.trace("{} rightTuples {}", indent(offset), bm.getStagedRightTuples().toStringSizes()); @@ -612,7 +611,7 @@ private void doRiaNode(ActivationsManager activationsManager, SegmentMemory[] smems, int smemIndex, Memory nodeMem, - BetaMemoryImpl bm, + BetaMemory bm, LinkedList stack, RuleExecutor executor) { RiaPathMemory pathMem = bm.getRiaRuleMemory(); @@ -649,29 +648,29 @@ private void doRiaNode2(ReteEvaluator reteEvaluator, ObjectSink[] sinks = riaNode.getObjectSinkPropagator().getSinks(); BetaNode betaNode = (BetaNode) sinks[0]; - BetaMemoryImpl bm; + BetaMemory bm; Memory nodeMem = reteEvaluator.getNodeMemory(betaNode); if (NodeTypeEnums.AccumulateNode == betaNode.getType()) { bm = ((AccumulateMemory) nodeMem).getBetaMemory(); } else { - bm = (BetaMemoryImpl) nodeMem; + bm = (BetaMemory) nodeMem; } TupleSets rightTuples = bm.getStagedRightTuples(); // Build up iteration array for other sinks BetaNode[] bns = null; - BetaMemoryImpl[] bms = null; + BetaMemory[] bms = null; int length = sinks.length; if (length > 1) { bns = new BetaNode[sinks.length - 1]; - bms = new BetaMemoryImpl[sinks.length - 1]; + bms = new BetaMemory[sinks.length - 1]; for (int i = 1; i < length; i++) { bns[i - 1] = (BetaNode) sinks[i]; Memory nodeMem2 = reteEvaluator.getNodeMemory(bns[i - 1]); if (NodeTypeEnums.AccumulateNode == betaNode.getType()) { bms[i - 1] = ((AccumulateMemory) nodeMem2).getBetaMemory(); } else { - bms[i - 1] = (BetaMemoryImpl) nodeMem2; + bms[i - 1] = (BetaMemory) nodeMem2; } } } diff --git a/drools-core/src/main/java/org/drools/core/phreak/SegmentPropagator.java b/drools-core/src/main/java/org/drools/core/phreak/SegmentPropagator.java index 6182373acc5..70779468ac0 100644 --- a/drools-core/src/main/java/org/drools/core/phreak/SegmentPropagator.java +++ b/drools-core/src/main/java/org/drools/core/phreak/SegmentPropagator.java @@ -20,9 +20,7 @@ import java.util.Iterator; -import org.drools.core.common.BaseNode; import org.drools.core.common.ReteEvaluator; -import org.drools.core.common.SuperCacheFixer; import org.drools.core.common.TupleSets; import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; @@ -138,7 +136,7 @@ private static void updateChildLeftTupleDuringInsert(TupleImpl childLeftTuple, T break; default: // no clash, so just add - if (SuperCacheFixer.getSink(childLeftTuple).getType() == AccumulateNode ) { + if (childLeftTuple.getSink().getType() == AccumulateNode ) { trgLeftTuples.addInsert(childLeftTuple); } else { trgLeftTuples.addUpdate(childLeftTuple); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/AccumulateNode.java b/drools-core/src/main/java/org/drools/core/reteoo/AccumulateNode.java index 69042bcad40..2ff681e4f66 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/AccumulateNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/AccumulateNode.java @@ -184,7 +184,7 @@ public boolean equals( final Object object ) { * Creates a BetaMemory for the BetaNode's memory. */ public Memory createMemory(final RuleBaseConfiguration config, ReteEvaluator reteEvaluator) { - BetaMemoryImpl betaMemory = (BetaMemoryImpl) this.constraints.createBetaMemory(config, NodeTypeEnums.AccumulateNode); + BetaMemory betaMemory = (BetaMemory) this.constraints.createBetaMemory(config, NodeTypeEnums.AccumulateNode); AccumulateMemory memory = this.accumulate.isMultiFunction() ? new MultiAccumulateMemory(betaMemory, this.accumulate.getAccumulators()) : new SingleAccumulateMemory(betaMemory, this.accumulate.getAccumulators()[0]); @@ -199,14 +199,14 @@ public static abstract class AccumulateMemory extends AbstractLinkedListNode betaMemory; + private final BetaMemory betaMemory; public Object resultsContext; - protected AccumulateMemory( BetaMemoryImpl betaMemory) { + protected AccumulateMemory( BetaMemory betaMemory) { this.betaMemory = betaMemory; } - public BetaMemoryImpl getBetaMemory() { + public BetaMemory getBetaMemory() { return this.betaMemory; } @@ -249,7 +249,7 @@ public static class SingleAccumulateMemory extends AccumulateMemory { private final Accumulator accumulator; - public SingleAccumulateMemory(BetaMemoryImpl betaMemory, Accumulator accumulator) { + public SingleAccumulateMemory(BetaMemory betaMemory, Accumulator accumulator) { super( betaMemory ); this.accumulator = accumulator; } @@ -264,7 +264,7 @@ public static class MultiAccumulateMemory extends AccumulateMemory { private final Accumulator[] accumulators; - public MultiAccumulateMemory(BetaMemoryImpl betaMemory, Accumulator[] accumulators) { + public MultiAccumulateMemory(BetaMemory betaMemory, Accumulator[] accumulators) { super( betaMemory ); this.accumulators = accumulators; } @@ -381,7 +381,7 @@ public void retractRightTuple( final TupleImpl rightTuple, final ReteEvaluator reteEvaluator ) { final AccumulateMemory memory = (AccumulateMemory) reteEvaluator.getNodeMemory( this ); - BetaMemoryImpl bm = memory.getBetaMemory(); + BetaMemory bm = memory.getBetaMemory(); rightTuple.setPropagationContext( pctx ); doDeleteRightTuple( rightTuple, reteEvaluator, bm ); } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/AsyncSendNode.java b/drools-core/src/main/java/org/drools/core/reteoo/AsyncSendNode.java index c771bad265a..1d1665a0a26 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/AsyncSendNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/AsyncSendNode.java @@ -169,10 +169,10 @@ public ObjectTypeConf getObjectTypeConf( ReteEvaluator reteEvaluator ) { } public T createMemory(final RuleBaseConfiguration config, ReteEvaluator reteEvaluator) { - BetaMemoryImpl beta = new BetaMemoryImpl(new TupleList(), - null, - this.betaConstraints.createContext(), - NodeTypeEnums.FromNode ); + BetaMemory beta = new BetaMemory(new TupleList(), + null, + this.betaConstraints.createContext(), + NodeTypeEnums.FromNode ); return (T) new AsyncSendMemory( beta, this.dataProvider ); } @@ -228,10 +228,10 @@ public static class AsyncSendMemory extends AbstractLinkedListNode private DataProvider dataProvider; - private final BetaMemoryImpl betaMemory; + private final BetaMemory betaMemory; public Object providerContext; - public AsyncSendMemory( BetaMemoryImpl betaMemory, + public AsyncSendMemory( BetaMemory betaMemory, DataProvider dataProvider) { this.betaMemory = betaMemory; this.dataProvider = dataProvider; diff --git a/drools-core/src/main/java/org/drools/core/reteoo/BetaMemory.java b/drools-core/src/main/java/org/drools/core/reteoo/BetaMemory.java index b6cd885ed5e..fd83472bca7 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/BetaMemory.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/BetaMemory.java @@ -18,12 +18,158 @@ */ package org.drools.core.reteoo; -public interface BetaMemory { - TupleMemory getRightTupleMemory(); +import org.drools.core.common.Memory; +import org.drools.core.common.ReteEvaluator; +import org.drools.core.common.TupleSets; +import org.drools.core.common.TupleSetsImpl; +import org.drools.core.reteoo.RightInputAdapterNode.RiaPathMemory; +import org.drools.core.util.AbstractLinkedListNode; - TupleMemory getLeftTupleMemory(); +public class BetaMemory extends AbstractLinkedListNode implements SegmentNodeMemory { - C getContext(); + private TupleMemory leftTupleMemory; + private TupleMemory rightTupleMemory; + private TupleSets stagedRightTuples; + private C context; + // the node type this memory belongs to + private int nodeType; + private SegmentMemory segmentMemory; + private long nodePosMaskBit; + private int counter; + private RiaPathMemory riaRuleMemory; - void reset(); + public BetaMemory() { + } + + public BetaMemory(final TupleMemory tupleMemory, + final TupleMemory objectMemory, + final C context, + final int nodeType) { + this.leftTupleMemory = tupleMemory; + this.rightTupleMemory = objectMemory; + this.stagedRightTuples = new TupleSetsImpl(); + this.context = context; + this.nodeType = nodeType; + } + + public TupleSets getStagedRightTuples() { + return stagedRightTuples; + } + + public void setStagedRightTuples(TupleSets stagedRightTuples) { + this.stagedRightTuples = stagedRightTuples; + } + + public TupleMemory getRightTupleMemory() { + return this.rightTupleMemory; + } + + public TupleMemory getLeftTupleMemory() { + return this.leftTupleMemory; + } + + public RiaPathMemory getRiaRuleMemory() { + return riaRuleMemory; + } + + public void setRiaRuleMemory(RiaPathMemory riaRuleMemory) { + this.riaRuleMemory = riaRuleMemory; + } + + /** + * @return the context + */ + public C getContext() { + return context; + } + + public boolean linkNode(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator) { + return linkNode(tupleSource, reteEvaluator, true); + } + + public boolean linkNode(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator, boolean notify) { + if (segmentMemory == null) { + segmentMemory = getOrCreateSegmentMemory( tupleSource, reteEvaluator ); + } + return notify ? + segmentMemory.linkNode(nodePosMaskBit, reteEvaluator) : + segmentMemory.linkNodeWithoutRuleNotify(nodePosMaskBit); + } + + public boolean unlinkNode(ReteEvaluator reteEvaluator) { + return segmentMemory.unlinkNode(nodePosMaskBit, reteEvaluator); + } + + public int getNodeType() { + return this.nodeType; + } + + public SegmentMemory getSegmentMemory() { + return segmentMemory; + } + + public void setSegmentMemory(SegmentMemory segmentMemory) { + this.segmentMemory = segmentMemory; + } + + public long getNodePosMaskBit() { + return nodePosMaskBit; + } + + public void setNodePosMaskBit(long nodePosMaskBit) { + this.nodePosMaskBit = nodePosMaskBit; + } + + public int getCounter() { + return counter; + } + + public void setCounter(int counter) { + this.counter = counter; + } + + public int getAndIncCounter() { + return counter++; + } + + public int getAndDecCounter() { + return counter--; + } + + public boolean setNodeDirty(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator) { + return setNodeDirty(tupleSource, reteEvaluator, true); + } + + public boolean setNodeDirty(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator, boolean notify) { + if (segmentMemory == null) { + segmentMemory = getOrCreateSegmentMemory( tupleSource, reteEvaluator ); + } + return notify ? + segmentMemory.notifyRuleLinkSegment(reteEvaluator, nodePosMaskBit) : + segmentMemory.linkSegmentWithoutRuleNotify(nodePosMaskBit); + } + + public void setNodeDirtyWithoutNotify() { + if (segmentMemory != null) { + segmentMemory.updateDirtyNodeMask( nodePosMaskBit ); + } + } + + public void setNodeCleanWithoutNotify() { + if (segmentMemory != null) { + segmentMemory.updateCleanNodeMask( nodePosMaskBit ); + } + } + + @Override + public void reset() { + if (leftTupleMemory != null) { + leftTupleMemory.clear(); + } + if (rightTupleMemory != null) { + rightTupleMemory.clear(); + } + stagedRightTuples.resetAll(); + counter = 0; + } } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/BetaMemoryImpl.java b/drools-core/src/main/java/org/drools/core/reteoo/BetaMemoryImpl.java deleted file mode 100644 index 29262a6c292..00000000000 --- a/drools-core/src/main/java/org/drools/core/reteoo/BetaMemoryImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.drools.core.reteoo; - -import org.drools.core.common.Memory; -import org.drools.core.common.ReteEvaluator; -import org.drools.core.common.TupleSets; -import org.drools.core.common.TupleSetsImpl; -import org.drools.core.reteoo.RightInputAdapterNode.RiaPathMemory; -import org.drools.core.util.AbstractLinkedListNode; - -public class BetaMemoryImpl extends AbstractLinkedListNode - implements - SegmentNodeMemory, BetaMemory { - - private static final long serialVersionUID = 510l; - private TupleMemory leftTupleMemory; - private TupleMemory rightTupleMemory; - private TupleSets stagedRightTuples; - private C context; - // the node type this memory belongs to - private int nodeType; - private SegmentMemory segmentMemory; - private long nodePosMaskBit; - private int counter; - private RiaPathMemory riaRuleMemory; - - public BetaMemoryImpl() { - } - - public BetaMemoryImpl(final TupleMemory tupleMemory, - final TupleMemory objectMemory, - final C context, - final int nodeType) { - this.leftTupleMemory = tupleMemory; - this.rightTupleMemory = objectMemory; - this.stagedRightTuples = new TupleSetsImpl(); - this.context = context; - this.nodeType = nodeType; - } - - public TupleSets getStagedRightTuples() { - return stagedRightTuples; - } - - public void setStagedRightTuples(TupleSets stagedRightTuples) { - this.stagedRightTuples = stagedRightTuples; - } - - @Override - public TupleMemory getRightTupleMemory() { - return this.rightTupleMemory; - } - - @Override - public TupleMemory getLeftTupleMemory() { - return this.leftTupleMemory; - } - - public RiaPathMemory getRiaRuleMemory() { - return riaRuleMemory; - } - - public void setRiaRuleMemory(RiaPathMemory riaRuleMemory) { - this.riaRuleMemory = riaRuleMemory; - } - - /** - * @return the context - */ - @Override - public C getContext() { - return context; - } - - public boolean linkNode(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator) { - return linkNode(tupleSource, reteEvaluator, true); - } - - public boolean linkNode(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator, boolean notify) { - if (segmentMemory == null) { - segmentMemory = getOrCreateSegmentMemory( tupleSource, reteEvaluator ); - } - return notify ? - segmentMemory.linkNode(nodePosMaskBit, reteEvaluator) : - segmentMemory.linkNodeWithoutRuleNotify(nodePosMaskBit); - } - - public boolean unlinkNode(ReteEvaluator reteEvaluator) { - return segmentMemory.unlinkNode(nodePosMaskBit, reteEvaluator); - } - - public int getNodeType() { - return this.nodeType; - } - - public SegmentMemory getSegmentMemory() { - return segmentMemory; - } - - public void setSegmentMemory(SegmentMemory segmentMemory) { - this.segmentMemory = segmentMemory; - } - - public long getNodePosMaskBit() { - return nodePosMaskBit; - } - - public void setNodePosMaskBit(long nodePosMaskBit) { - this.nodePosMaskBit = nodePosMaskBit; - } - - public int getCounter() { - return counter; - } - - public void setCounter(int counter) { - this.counter = counter; - } - - public int getAndIncCounter() { - return counter++; - } - - public int getAndDecCounter() { - return counter--; - } - - public boolean setNodeDirty(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator) { - return setNodeDirty(tupleSource, reteEvaluator, true); - } - - public boolean setNodeDirty(LeftTupleSource tupleSource, ReteEvaluator reteEvaluator, boolean notify) { - if (segmentMemory == null) { - segmentMemory = getOrCreateSegmentMemory( tupleSource, reteEvaluator ); - } - return notify ? - segmentMemory.notifyRuleLinkSegment(reteEvaluator, nodePosMaskBit) : - segmentMemory.linkSegmentWithoutRuleNotify(nodePosMaskBit); - } - - public void setNodeDirtyWithoutNotify() { - if (segmentMemory != null) { - segmentMemory.updateDirtyNodeMask( nodePosMaskBit ); - } - } - - public void setNodeCleanWithoutNotify() { - if (segmentMemory != null) { - segmentMemory.updateCleanNodeMask( nodePosMaskBit ); - } - } - - @Override - public void reset() { - if (leftTupleMemory != null) { - leftTupleMemory.clear(); - } - if (rightTupleMemory != null) { - rightTupleMemory.clear(); - } - stagedRightTuples.resetAll(); - counter = 0; - } -} diff --git a/drools-core/src/main/java/org/drools/core/reteoo/BetaNode.java b/drools-core/src/main/java/org/drools/core/reteoo/BetaNode.java index 78ed61e4a29..ebffdcc1149 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/BetaNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/BetaNode.java @@ -251,7 +251,7 @@ private void setUnificationJoin() { @Override public void assertObject( InternalFactHandle factHandle, PropagationContext pctx, ReteEvaluator reteEvaluator ) { - final BetaMemoryImpl memory = (BetaMemoryImpl) getBetaMemoryFromRightInput(this, reteEvaluator); + final BetaMemory memory = (BetaMemory) getBetaMemoryFromRightInput(this, reteEvaluator); RightTuple rightTuple = createRightTuple(factHandle, this, pctx); @@ -284,7 +284,7 @@ public void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples mod // we skipped this node, due to alpha hashing, so retract now rightTuple.setPropagationContext( context ); - BetaMemoryImpl bm = getBetaMemory(rightTuple.getSink(), reteEvaluator); + BetaMemory bm = getBetaMemory(rightTuple.getSink(), reteEvaluator); (( BetaNode ) rightTuple.getSink()).doDeleteRightTuple(rightTuple, reteEvaluator, bm); rightTuple = modifyPreviousTuples.peekRightTuple(partitionId); } @@ -296,7 +296,7 @@ public void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples mod // RightTuple previously existed, so continue as modify rightTuple.setPropagationContext( context ); // only update, if the mask intersects - BetaMemoryImpl bm = getBetaMemory(this, reteEvaluator); + BetaMemory bm = getBetaMemory(this, reteEvaluator); rightTuple.setPropagationContext( context ); doUpdateRightTuple(rightTuple, reteEvaluator, bm); } else if (rightTuple.getMemory() != null) { @@ -317,7 +317,7 @@ protected void reorderRightTuple(ReteEvaluator reteEvaluator, TupleImpl rightTup public void doDeleteRightTuple(final TupleImpl rightTuple, final ReteEvaluator reteEvaluator, - final BetaMemoryImpl memory) { + final BetaMemory memory) { TupleSets stagedRightTuples = memory.getStagedRightTuples(); boolean stagedDeleteWasEmpty = stagedRightTuples.addDelete(rightTuple); @@ -340,7 +340,7 @@ public void doDeleteRightTuple(final TupleImpl rightTuple, public void doUpdateRightTuple(final TupleImpl rightTuple, final ReteEvaluator reteEvaluator, - final BetaMemoryImpl memory) { + final BetaMemory memory) { TupleSets stagedRightTuples = memory.getStagedRightTuples(); boolean stagedUpdateWasEmpty = stagedRightTuples.addUpdate( rightTuple ); @@ -510,12 +510,12 @@ public void byPassModifyToBetaNode (final InternalFactHandle factHandle, } - public static BetaMemoryImpl getBetaMemory(NetworkNode node, ReteEvaluator reteEvaluator) { - BetaMemoryImpl bm; + public static BetaMemory getBetaMemory(NetworkNode node, ReteEvaluator reteEvaluator) { + BetaMemory bm; if ( node.getType() == NodeTypeEnums.AccumulateNode ) { bm = ((AccumulateMemory)reteEvaluator.getNodeMemory((AccumulateNode)node)).getBetaMemory(); } else { - bm = ((BetaMemoryImpl)reteEvaluator.getNodeMemory((BetaNode)node)); + bm = ((BetaMemory)reteEvaluator.getNodeMemory((BetaNode)node)); } return bm; } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/ExistsNode.java b/drools-core/src/main/java/org/drools/core/reteoo/ExistsNode.java index bb2f0023ee9..ead9220acd9 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/ExistsNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/ExistsNode.java @@ -20,7 +20,6 @@ import org.drools.base.reteoo.NodeTypeEnums; import org.drools.core.common.BetaConstraints; -import org.drools.core.common.InternalFactHandle; import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; import org.drools.core.reteoo.builder.BuildContext; @@ -72,7 +71,7 @@ public int getType() { public void retractRightTuple(final TupleImpl rightTuple, final PropagationContext pctx, final ReteEvaluator reteEvaluator) { - final BetaMemoryImpl memory = (BetaMemoryImpl) reteEvaluator.getNodeMemory(this); + final BetaMemory memory = (BetaMemory) reteEvaluator.getNodeMemory(this); rightTuple.setPropagationContext( pctx ); doDeleteRightTuple( rightTuple, reteEvaluator, memory ); } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/FromNode.java b/drools-core/src/main/java/org/drools/core/reteoo/FromNode.java index 344344c4b9e..e973ae82a9b 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/FromNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/FromNode.java @@ -237,10 +237,10 @@ public void addToCreatedHandlesMap(final Map matches, public T createMemory(final RuleBaseConfiguration config, ReteEvaluator reteEvaluator) { - BetaMemoryImpl beta = new BetaMemoryImpl(new TupleList(), - null, - this.betaConstraints.createContext(), - NodeTypeEnums.FromNode ); + BetaMemory beta = new BetaMemory(new TupleList(), + null, + this.betaConstraints.createContext(), + NodeTypeEnums.FromNode ); return (T) new FromMemory( beta, this.dataProvider ); } @@ -297,10 +297,10 @@ public static class FromMemory extends AbstractLinkedListNode private DataProvider dataProvider; - private final BetaMemoryImpl betaMemory; + private final BetaMemory betaMemory; public Object providerContext; - public FromMemory(BetaMemoryImpl betaMemory, + public FromMemory(BetaMemory betaMemory, DataProvider dataProvider) { this.betaMemory = betaMemory; this.dataProvider = dataProvider; @@ -319,7 +319,7 @@ public void setSegmentMemory(SegmentMemory segmentMemory) { betaMemory.setSegmentMemory(segmentMemory); } - public BetaMemoryImpl getBetaMemory() { + public BetaMemory getBetaMemory() { return betaMemory; } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/JoinNode.java b/drools-core/src/main/java/org/drools/core/reteoo/JoinNode.java index 710b6d00e6f..7f464d7c93b 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/JoinNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/JoinNode.java @@ -20,7 +20,6 @@ import org.drools.base.reteoo.NodeTypeEnums; import org.drools.core.common.BetaConstraints; -import org.drools.core.common.InternalFactHandle; import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; import org.drools.core.reteoo.builder.BuildContext; @@ -58,7 +57,7 @@ public String toString() { public void retractRightTuple( final TupleImpl rightTuple, final PropagationContext pctx, final ReteEvaluator reteEvaluator ) { - final BetaMemoryImpl memory = (BetaMemoryImpl) reteEvaluator.getNodeMemory(this); + final BetaMemory memory = (BetaMemory) reteEvaluator.getNodeMemory(this); rightTuple.setPropagationContext( pctx ); doDeleteRightTuple( rightTuple, reteEvaluator, memory ); } diff --git a/drools-core/src/main/java/org/drools/core/reteoo/NotNode.java b/drools-core/src/main/java/org/drools/core/reteoo/NotNode.java index c75b5fe776d..6d1d8d58120 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/NotNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/NotNode.java @@ -85,7 +85,7 @@ public String toString() { public void assertObject( final InternalFactHandle factHandle, final PropagationContext pctx, final ReteEvaluator reteEvaluator ) { - final BetaMemoryImpl memory = (BetaMemoryImpl) getBetaMemoryFromRightInput(this, reteEvaluator); + final BetaMemory memory = (BetaMemory) getBetaMemoryFromRightInput(this, reteEvaluator); TupleImpl rightTuple = createRightTuple( factHandle, this, @@ -116,14 +116,14 @@ public void assertObject( final InternalFactHandle factHandle, public void retractRightTuple(final TupleImpl rightTuple, final PropagationContext pctx, final ReteEvaluator reteEvaluator) { - final BetaMemoryImpl memory = (BetaMemoryImpl) reteEvaluator.getNodeMemory(this); + final BetaMemory memory = (BetaMemory) reteEvaluator.getNodeMemory(this); rightTuple.setPropagationContext( pctx ); doDeleteRightTuple( rightTuple, reteEvaluator, memory ); } public void doDeleteRightTuple(final TupleImpl rightTuple, final ReteEvaluator reteEvaluator, - final BetaMemoryImpl memory) { + final BetaMemory memory) { TupleSets stagedRightTuples = memory.getStagedRightTuples(); boolean stagedDeleteWasEmpty = stagedRightTuples.addDelete( rightTuple ); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/ReactiveFromNode.java b/drools-core/src/main/java/org/drools/core/reteoo/ReactiveFromNode.java index d33d029e02f..a37a9d992fd 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/ReactiveFromNode.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/ReactiveFromNode.java @@ -24,8 +24,6 @@ import org.drools.base.rule.constraint.AlphaNodeFieldConstraint; import org.drools.core.RuleBaseConfiguration; import org.drools.core.common.BetaConstraints; -import org.drools.core.common.InternalFactHandle; -import org.drools.core.common.PropagationContext; import org.drools.core.common.ReteEvaluator; import org.drools.core.common.TupleSets; import org.drools.core.common.TupleSetsImpl; @@ -47,10 +45,10 @@ public ReactiveFromNode(final int id, } public ReactiveFromMemory createMemory(final RuleBaseConfiguration config, ReteEvaluator reteEvaluator) { - BetaMemoryImpl beta = new BetaMemoryImpl(new TupleList(), - null, - this.betaConstraints.createContext(), - NodeTypeEnums.FromNode ); + BetaMemory beta = new BetaMemory(new TupleList(), + null, + this.betaConstraints.createContext(), + NodeTypeEnums.FromNode ); return new ReactiveFromMemory( beta, this.dataProvider ); } @@ -65,7 +63,7 @@ public static class ReactiveFromMemory extends FromNode.FromMemory { private final TupleSets stagedLeftTuples; - public ReactiveFromMemory(BetaMemoryImpl betaMemory, + public ReactiveFromMemory(BetaMemory betaMemory, DataProvider dataProvider) { super(betaMemory, dataProvider); stagedLeftTuples = new TupleSetsImpl(); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/SegmentMemory.java b/drools-core/src/main/java/org/drools/core/reteoo/SegmentMemory.java index 9217a899b43..90968320ee9 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/SegmentMemory.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/SegmentMemory.java @@ -609,8 +609,8 @@ public abstract static class MemoryPrototype { protected long nodePosMaskBit; public static MemoryPrototype get(Memory memory) { - if (memory instanceof BetaMemoryImpl) { - BetaMemoryImpl betaMemory = (BetaMemoryImpl)memory; + if (memory instanceof BetaMemory) { + BetaMemory betaMemory = (BetaMemory)memory; return new BetaMemoryPrototype(betaMemory.getNodePosMaskBit(), betaMemory.getRiaRuleMemory() != null ? betaMemory.getRiaRuleMemory().getRightInputAdapterNode() : null); } if (memory instanceof LeftInputAdapterNode.LiaNodeMemory) { @@ -624,7 +624,7 @@ public static MemoryPrototype get(Memory memory) { return new TimerMemoryPrototype(((TimerNodeMemory)memory).getNodePosMaskBit()); } if (memory instanceof AccumulateNode.AccumulateMemory) { - BetaMemoryImpl betaMemory = ((AccumulateNode.AccumulateMemory)memory).getBetaMemory(); + BetaMemory betaMemory = ((AccumulateNode.AccumulateMemory)memory).getBetaMemory(); return new AccumulateMemoryPrototype(new BetaMemoryPrototype( betaMemory.getNodePosMaskBit(), betaMemory.getRiaRuleMemory() != null ? betaMemory.getRiaRuleMemory().getRightInputAdapterNode() : null) ); } if (memory instanceof ReactiveFromNode.ReactiveFromMemory) { @@ -654,7 +654,7 @@ public BetaMemoryPrototype(long nodePosMaskBit, RightInputAdapterNode riaNode) { @Override public void populateMemory(ReteEvaluator reteEvaluator, Memory memory) { - BetaMemoryImpl betaMemory = (BetaMemoryImpl)memory; + BetaMemory betaMemory = (BetaMemory)memory; betaMemory.setNodePosMaskBit(nodePosMaskBit); if (riaNode != null) { RiaPathMemory riaMem = (RiaPathMemory) reteEvaluator.getNodeMemories().peekNodeMemory(riaNode); diff --git a/drools-core/src/main/java/org/drools/core/reteoo/SingleObjectSinkAdapter.java b/drools-core/src/main/java/org/drools/core/reteoo/SingleObjectSinkAdapter.java index aebdcea7457..b6a93ad781b 100644 --- a/drools-core/src/main/java/org/drools/core/reteoo/SingleObjectSinkAdapter.java +++ b/drools-core/src/main/java/org/drools/core/reteoo/SingleObjectSinkAdapter.java @@ -92,14 +92,14 @@ public void doLinkRiaNode(ReteEvaluator reteEvaluator) { } public static void staticDoLinkRiaNode(ObjectSink sink, ReteEvaluator reteEvaluator) { - BetaMemoryImpl bm; + BetaMemory bm; if ( sink.getType() == NodeTypeEnums.AccumulateNode ) { AccumulateNode accnode = ( AccumulateNode ) sink; AccumulateMemory accMem = ( AccumulateMemory ) reteEvaluator.getNodeMemory( accnode ); bm = accMem.getBetaMemory(); } else if ( NodeTypeEnums.isBetaNode( sink ) ) { BetaNode betaNode = ( BetaNode ) sink; - bm = (BetaMemoryImpl) BetaNode.getBetaMemoryFromRightInput(betaNode, reteEvaluator); + bm = (BetaMemory) BetaNode.getBetaMemoryFromRightInput(betaNode, reteEvaluator); } else { throw new RuntimeException( "Should not be possible to have link into a node of type" + sink); } @@ -118,14 +118,14 @@ public void doUnlinkRiaNode( ReteEvaluator reteEvaluator) { } public static void staticDoUnlinkRiaNode(ObjectSink sink, ReteEvaluator reteEvaluator) { - BetaMemoryImpl bm; + BetaMemory bm; if ( sink.getType() == NodeTypeEnums.AccumulateNode ) { AccumulateNode accnode = ( AccumulateNode ) sink; AccumulateMemory accMem = ( AccumulateMemory ) reteEvaluator.getNodeMemory( accnode ); bm = accMem.getBetaMemory(); } else if ( NodeTypeEnums.isBetaNode( sink ) ) { BetaNode betaNode = ( BetaNode ) sink; - bm = (BetaMemoryImpl) BetaNode.getBetaMemoryFromRightInput(betaNode, reteEvaluator); + bm = (BetaMemory) BetaNode.getBetaMemoryFromRightInput(betaNode, reteEvaluator); } else { throw new RuntimeException( "Should not be possible to have link into a node of type" + sink); } diff --git a/drools-core/src/main/java/org/drools/core/util/index/IndexFactory.java b/drools-core/src/main/java/org/drools/core/util/index/IndexFactory.java index 55e52e82e2c..1666d37004e 100644 --- a/drools-core/src/main/java/org/drools/core/util/index/IndexFactory.java +++ b/drools-core/src/main/java/org/drools/core/util/index/IndexFactory.java @@ -21,25 +21,25 @@ import org.drools.base.rule.ContextEntry; import org.drools.base.util.index.ConstraintTypeOperator; import org.drools.core.RuleBaseConfiguration; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.TupleMemory; import org.drools.base.rule.constraint.BetaConstraint; public interface IndexFactory { - static BetaMemoryImpl createBetaMemory(RuleBaseConfiguration config, int nodeType, BetaConstraint... constraints) { + static BetaMemory createBetaMemory(RuleBaseConfiguration config, int nodeType, BetaConstraint... constraints) { if (config.getCompositeKeyDepth() < 1) { - return new BetaMemoryImpl(config.isSequential() ? null : new TupleList(), - new TupleList(), - createContext(constraints), - nodeType ); + return new BetaMemory(config.isSequential() ? null : new TupleList(), + new TupleList(), + createContext(constraints), + nodeType ); } IndexSpec indexSpec = new IndexSpec(nodeType, constraints, config); - return new BetaMemoryImpl(createLeftMemory(config, indexSpec), - createRightMemory(config, indexSpec), - createContext(constraints), - nodeType ); + return new BetaMemory(createLeftMemory(config, indexSpec), + createRightMemory(config, indexSpec), + createContext(constraints), + nodeType ); } private static TupleMemory createRightMemory(RuleBaseConfiguration config, IndexSpec indexSpec) { diff --git a/drools-core/src/test/java/org/drools/core/reteoo/ReteMemoryChecker.java b/drools-core/src/test/java/org/drools/core/reteoo/ReteMemoryChecker.java index 63a64320b12..c937e5fa182 100644 --- a/drools-core/src/test/java/org/drools/core/reteoo/ReteMemoryChecker.java +++ b/drools-core/src/test/java/org/drools/core/reteoo/ReteMemoryChecker.java @@ -48,7 +48,7 @@ private static void checkNodeMemory(InternalWorkingMemory wm, BaseNode node) { if ( !( memory instanceof AccumulateNode.AccumulateMemory ) ) { throw new RuntimeException( "Invalid memory type. Node: " + node + " has memory " + memory ); } - } else if ( !( memory instanceof BetaMemoryImpl) ) { + } else if ( !( memory instanceof BetaMemory) ) { throw new RuntimeException( "Invalid memory type. Node: " + node + " has memory " + memory ); } } else if ( NodeTypeEnums.FromNode == node.getType() ) { diff --git a/drools-kiesession/src/test/java/org/drools/core/positional/PositionalConstraint.java b/drools-kiesession/src/test/java/org/drools/core/positional/PositionalConstraint.java index 834b5a682a1..271ae7969d8 100644 --- a/drools-kiesession/src/test/java/org/drools/core/positional/PositionalConstraint.java +++ b/drools-kiesession/src/test/java/org/drools/core/positional/PositionalConstraint.java @@ -26,7 +26,6 @@ import org.drools.core.positional.Predicates.Predicate3; import org.drools.core.positional.Predicates.Predicate4; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.Tuple; import org.drools.core.reteoo.TupleMemory; import org.drools.core.reteoo.builder.BuildContext; @@ -213,16 +212,16 @@ public boolean isEmpty() { public BetaMemory createBetaMemory(RuleBaseConfiguration config, int nodeType) { if (config.getCompositeKeyDepth() < 1) { - return new BetaMemoryImpl(config.isSequential() ? null : new TupleList(), - new TupleList(), - createContext(), - nodeType ); - } - - return new BetaMemoryImpl(createLeftMemory(config, indexSpec), - createRightMemory(config, indexSpec), + return new BetaMemory(config.isSequential() ? null : new TupleList(), + new TupleList(), createContext(), nodeType ); + } + + return new BetaMemory(createLeftMemory(config, indexSpec), + createRightMemory(config, indexSpec), + createContext(), + nodeType ); } private static TupleMemory createRightMemory(RuleBaseConfiguration config, IndexSpec indexSpec) { diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java index 2bdb9144c53..9693d65b11c 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/NodeSegmentUnlinkingTest.java @@ -30,7 +30,7 @@ import org.drools.core.common.PropagationContextFactory; import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.phreak.BuildtimeSegmentUtilities; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.PathEndNode; import org.drools.core.reteoo.SegmentMemory.SegmentPrototype; import org.drools.core.reteoo.TerminalNode; @@ -251,16 +251,16 @@ public void testSingleNodeinSegment() { Arrays.stream(protos).forEach( p -> p.setPathEndNodes( new PathEndNode[0])); createSegmentMemory( n2, ksession ); - BetaMemoryImpl bm = (BetaMemoryImpl) ksession.getNodeMemory(n1); + BetaMemory bm = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm.getSegmentMemory()).isNull(); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + bm = (BetaMemory) ksession.getNodeMemory(n3); assertThat(bm.getSegmentMemory()).isNull(); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n4); + bm = (BetaMemory) ksession.getNodeMemory(n4); assertThat(bm.getSegmentMemory()).isNull(); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n2); + bm = (BetaMemory) ksession.getNodeMemory(n2); assertThat(bm.getNodePosMaskBit()).isEqualTo(1); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(1); } @@ -280,7 +280,7 @@ public void testLiaNodeInitialisation() { assertThat(liaMem.getNodePosMaskBit()).isEqualTo(1); assertThat(liaMem.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); - BetaMemoryImpl bm1 = (BetaMemoryImpl) ksession.getNodeMemory(n1); + BetaMemory bm1 = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm1.getNodePosMaskBit()).isEqualTo(2); assertThat(bm1.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); @@ -294,7 +294,7 @@ public void testLiaNodeInitialisation() { assertThat(liaMem.getNodePosMaskBit()).isEqualTo(1); assertThat(liaMem.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); - bm1 = (BetaMemoryImpl) ksession.getNodeMemory(n1); + bm1 = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm1.getNodePosMaskBit()).isEqualTo(2); assertThat(bm1.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); } @@ -314,7 +314,7 @@ public void testLiaNodeLinking() { assertThat(liaMem.getNodePosMaskBit()).isEqualTo(1); assertThat(liaMem.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); - BetaMemoryImpl bm1 = (BetaMemoryImpl) ksession.getNodeMemory(n1); + BetaMemory bm1 = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm1.getNodePosMaskBit()).isEqualTo(2); assertThat(bm1.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); @@ -353,22 +353,22 @@ public void tesMultiNodeSegmentDifferentInitialisationPoints() { createSegmentMemory(n3, ksession); - BetaMemoryImpl bm = (BetaMemoryImpl) ksession.getNodeMemory(n1); + BetaMemory bm = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm.getSegmentMemory()).isNull(); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + bm = (BetaMemory) ksession.getNodeMemory(n3); assertThat(bm.getNodePosMaskBit()).isEqualTo(1); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n4); + bm = (BetaMemory) ksession.getNodeMemory(n4); assertThat(bm.getNodePosMaskBit()).isEqualTo(2); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n5); + bm = (BetaMemory) ksession.getNodeMemory(n5); assertThat(bm.getNodePosMaskBit()).isEqualTo(4); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n6); + bm = (BetaMemory) ksession.getNodeMemory(n6); assertThat(bm.getNodePosMaskBit()).isEqualTo(8); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); @@ -377,22 +377,22 @@ public void tesMultiNodeSegmentDifferentInitialisationPoints() { bm = createSegmentMemory( n4, ksession ); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n1); + bm = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm.getSegmentMemory()).isNull(); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + bm = (BetaMemory) ksession.getNodeMemory(n3); assertThat(bm.getNodePosMaskBit()).isEqualTo(1); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n4); + bm = (BetaMemory) ksession.getNodeMemory(n4); assertThat(bm.getNodePosMaskBit()).isEqualTo(2); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n5); + bm = (BetaMemory) ksession.getNodeMemory(n5); assertThat(bm.getNodePosMaskBit()).isEqualTo(4); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n6); + bm = (BetaMemory) ksession.getNodeMemory(n6); assertThat(bm.getNodePosMaskBit()).isEqualTo(8); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); @@ -401,22 +401,22 @@ public void tesMultiNodeSegmentDifferentInitialisationPoints() { createSegmentMemory( n5, ksession ); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n1); + bm = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm.getSegmentMemory()).isNull(); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + bm = (BetaMemory) ksession.getNodeMemory(n3); assertThat(bm.getNodePosMaskBit()).isEqualTo(1); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n4); + bm = (BetaMemory) ksession.getNodeMemory(n4); assertThat(bm.getNodePosMaskBit()).isEqualTo(2); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n5); + bm = (BetaMemory) ksession.getNodeMemory(n5); assertThat(bm.getNodePosMaskBit()).isEqualTo(4); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n6); + bm = (BetaMemory) ksession.getNodeMemory(n6); assertThat(bm.getNodePosMaskBit()).isEqualTo(8); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); @@ -425,22 +425,22 @@ public void tesMultiNodeSegmentDifferentInitialisationPoints() { createSegmentMemory( n6, ksession ); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n1); + bm = (BetaMemory) ksession.getNodeMemory(n1); assertThat(bm.getSegmentMemory()).isNull(); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + bm = (BetaMemory) ksession.getNodeMemory(n3); assertThat(bm.getNodePosMaskBit()).isEqualTo(1); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n4); + bm = (BetaMemory) ksession.getNodeMemory(n4); assertThat(bm.getNodePosMaskBit()).isEqualTo(2); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n5); + bm = (BetaMemory) ksession.getNodeMemory(n5); assertThat(bm.getNodePosMaskBit()).isEqualTo(4); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); - bm = (BetaMemoryImpl) ksession.getNodeMemory(n6); + bm = (BetaMemory) ksession.getNodeMemory(n6); assertThat(bm.getNodePosMaskBit()).isEqualTo(8); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); } @@ -456,7 +456,7 @@ public void testAllLinkedInWithJoinNodesOnly() { DefaultFactHandle f1 = (DefaultFactHandle) ksession.insert( "test1" ); n3.assertObject( f1, context, ksession ); - BetaMemoryImpl bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + BetaMemory bm = (BetaMemory) ksession.getNodeMemory(n3); assertThat(bm.getSegmentMemory().isSegmentLinked()).isFalse(); n4.assertObject( f1, context, ksession ); @@ -480,7 +480,7 @@ public void testAllLinkedInWithExistsNodesOnly() { DefaultFactHandle f1 = (DefaultFactHandle) ksession.insert( "test1" ); n3.assertObject( f1, context, ksession ); - BetaMemoryImpl bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + BetaMemory bm = (BetaMemory) ksession.getNodeMemory(n3); assertThat(bm.getSegmentMemory().isSegmentLinked()).isFalse(); n4.assertObject( f1, context, ksession ); @@ -493,9 +493,9 @@ public void testAllLinkedInWithExistsNodesOnly() { assertThat(bm.getSegmentMemory().isSegmentLinked()).isTrue(); // only after all 4 nodes are populated, is the segment linked in } - private static BetaMemoryImpl createSegmentMemory(BetaNode node, - InternalWorkingMemory wm) { - BetaMemoryImpl betaMemory = (BetaMemoryImpl) wm.getNodeMemory(node); + private static BetaMemory createSegmentMemory(BetaNode node, + InternalWorkingMemory wm) { + BetaMemory betaMemory = (BetaMemory) wm.getNodeMemory(node); if ( betaMemory.getSegmentMemory() == null ) { RuntimeSegmentUtilities.getOrCreateSegmentMemory(node, wm); } @@ -511,7 +511,7 @@ public void testAllLinkedInWithNotNodesOnly() { StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession(); - BetaMemoryImpl bm = (BetaMemoryImpl) ksession.getNodeMemory(n3); + BetaMemory bm = (BetaMemory) ksession.getNodeMemory(n3); createSegmentMemory( n3, ksession ); assertThat(bm.getSegmentMemory().isSegmentLinked()).isTrue(); // not nodes start off linked diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java index 22e9c9d9801..9fbafbdcdff 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingTest.java @@ -30,7 +30,7 @@ import org.drools.core.common.PropagationContextFactory; import org.drools.base.definitions.rule.impl.RuleImpl; import org.drools.core.phreak.BuildtimeSegmentUtilities; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.PathEndNode; import org.drools.core.reteoo.TerminalNode; import org.drools.kiesession.rulebase.InternalKnowledgeBase; @@ -218,7 +218,7 @@ public void testSegmentNodeReferencesToSegments() { StatefulKnowledgeSessionImpl wm = new StatefulKnowledgeSessionImpl( 1L, kBase ); - BetaMemoryImpl bm = null; + BetaMemory bm = null; List list; PathMemory rtn1Rs = wm.getNodeMemory( rtn1 ); @@ -312,7 +312,7 @@ public void testRuleSegmentLinking() { StatefulKnowledgeSessionImpl wm = new StatefulKnowledgeSessionImpl( 1L, kBase ); - BetaMemoryImpl bm = null; + BetaMemory bm = null; List list; PathMemory rtn1Rs = wm.getNodeMemory(rtn1); @@ -333,7 +333,7 @@ public void testRuleSegmentLinking() { assertThat(rtn3Rs.isRuleLinked()).isFalse(); // Link in Rule1 - bm = (BetaMemoryImpl) wm.getNodeMemory(n2); + bm = (BetaMemory) wm.getNodeMemory(n2); assertThat(bm.getSegmentMemory().isSegmentLinked()).isFalse(); DefaultFactHandle f2 = (DefaultFactHandle) wm.insert( "test2" ); @@ -345,7 +345,7 @@ public void testRuleSegmentLinking() { assertThat(rtn3Rs.isRuleLinked()).isFalse(); // Link in Rule2 - bm = (BetaMemoryImpl) wm.getNodeMemory(n5); + bm = (BetaMemory) wm.getNodeMemory(n5); assertThat(bm.getSegmentMemory().isSegmentLinked()).isFalse(); n5.assertObject( f1, context, wm ); @@ -378,9 +378,9 @@ public void testRuleSegmentLinking() { } } - private static BetaMemoryImpl createSegmentMemory(BetaNode node, - InternalWorkingMemory wm) { - BetaMemoryImpl betaMemory = (BetaMemoryImpl) wm.getNodeMemory(node); + private static BetaMemory createSegmentMemory(BetaNode node, + InternalWorkingMemory wm) { + BetaMemory betaMemory = (BetaMemory) wm.getNodeMemory(node); if ( betaMemory.getSegmentMemory() == null ) { RuntimeSegmentUtilities.getOrCreateSegmentMemory(node, wm); } diff --git a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java index daecda7f04a..fcd51e7d00c 100644 --- a/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java +++ b/drools-kiesession/src/test/java/org/drools/kiesession/RuleUnlinkingWithSegmentMemoryTest.java @@ -31,7 +31,7 @@ import org.drools.core.impl.RuleBaseFactory; import org.drools.core.phreak.RuntimeSegmentUtilities; import org.drools.core.phreak.BuildtimeSegmentUtilities; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.BetaNode; import org.drools.core.reteoo.ExistsNode; import org.drools.core.reteoo.JoinNode; @@ -215,7 +215,7 @@ public void testSegmentNodeReferencesToSegments() { StatefulKnowledgeSessionImpl wm = new StatefulKnowledgeSessionImpl( 1L, kBase ); - BetaMemoryImpl bm = null; + BetaMemory bm = null; List list; PathMemory rtn1Rs = wm.getNodeMemory( rtn1 ); @@ -229,7 +229,7 @@ public void testSegmentNodeReferencesToSegments() { // n1 RuntimeSegmentUtilities.getOrCreateSegmentMemory(n1, wm); - bm = (BetaMemoryImpl) wm.getNodeMemory(n1); + bm = (BetaMemory) wm.getNodeMemory(n1); assertThat(bm.getNodePosMaskBit()).isEqualTo(2); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(1); @@ -240,7 +240,7 @@ public void testSegmentNodeReferencesToSegments() { assertThat(list.contains(rtn3Rs)).isTrue(); // n2 - bm = (BetaMemoryImpl) wm.getNodeMemory(n2); + bm = (BetaMemory) wm.getNodeMemory(n2); assertThat(bm.getNodePosMaskBit()).isEqualTo(4); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(1); @@ -251,7 +251,7 @@ public void testSegmentNodeReferencesToSegments() { assertThat(list.contains(rtn3Rs)).isTrue(); // n3 - bm = (BetaMemoryImpl) wm.getNodeMemory(n3); + bm = (BetaMemory) wm.getNodeMemory(n3); assertThat(bm.getNodePosMaskBit()).isEqualTo(8); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(15); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(1); @@ -263,7 +263,7 @@ public void testSegmentNodeReferencesToSegments() { // n4 RuntimeSegmentUtilities.getOrCreateSegmentMemory(n4, wm); - bm = (BetaMemoryImpl) wm.getNodeMemory(n4); + bm = (BetaMemory) wm.getNodeMemory(n4); assertThat(bm.getNodePosMaskBit()).isEqualTo(1); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(2); @@ -273,7 +273,7 @@ public void testSegmentNodeReferencesToSegments() { assertThat(list.contains(rtn3Rs)).isTrue(); // n5 - bm = (BetaMemoryImpl) wm.getNodeMemory(n5); + bm = (BetaMemory) wm.getNodeMemory(n5); assertThat(bm.getNodePosMaskBit()).isEqualTo(2); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(3); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(2); @@ -284,7 +284,7 @@ public void testSegmentNodeReferencesToSegments() { // n6 RuntimeSegmentUtilities.getOrCreateSegmentMemory(n6, wm); - bm = (BetaMemoryImpl) wm.getNodeMemory(n6); + bm = (BetaMemory) wm.getNodeMemory(n6); assertThat(bm.getNodePosMaskBit()).isEqualTo(1); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(7); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(4); @@ -293,7 +293,7 @@ public void testSegmentNodeReferencesToSegments() { assertThat(list.contains(rtn3Rs)).isTrue(); // n7 - bm = (BetaMemoryImpl) wm.getNodeMemory(n7); + bm = (BetaMemory) wm.getNodeMemory(n7); assertThat(bm.getNodePosMaskBit()).isEqualTo(2); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(7); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(4); @@ -302,7 +302,7 @@ public void testSegmentNodeReferencesToSegments() { assertThat(list.contains(rtn3Rs)).isTrue(); // n8 - bm = (BetaMemoryImpl) wm.getNodeMemory(n8); + bm = (BetaMemory) wm.getNodeMemory(n8); assertThat(bm.getNodePosMaskBit()).isEqualTo(4); assertThat(bm.getSegmentMemory().getAllLinkedMaskTest()).isEqualTo(7); assertThat(bm.getSegmentMemory().getSegmentPosMaskBit()).isEqualTo(4); @@ -317,7 +317,7 @@ public void testRuleSegmentLinking() { StatefulKnowledgeSessionImpl wm = new StatefulKnowledgeSessionImpl( 1L, kBase ); - BetaMemoryImpl bm = null; + BetaMemory bm = null; List list; PathMemory rtn1Rs = wm.getNodeMemory( rtn1 ); @@ -338,7 +338,7 @@ public void testRuleSegmentLinking() { // Link in Rule1 - bm = (BetaMemoryImpl) wm.getNodeMemory(n2); + bm = (BetaMemory) wm.getNodeMemory(n2); assertThat(bm.getSegmentMemory().isSegmentLinked()).isFalse(); DefaultFactHandle f2 = (DefaultFactHandle) wm.insert( "test2" ); @@ -350,7 +350,7 @@ public void testRuleSegmentLinking() { assertThat(rtn3Rs.isRuleLinked()).isFalse(); // Link in Rule2 - bm = (BetaMemoryImpl) wm.getNodeMemory(n5); + bm = (BetaMemory) wm.getNodeMemory(n5); assertThat(bm.getSegmentMemory().isSegmentLinked()).isFalse(); n5.assertObject( f1, context, wm ); diff --git a/drools-metric/src/main/java/org/drools/metric/phreak/PhreakExistsNodeMetric.java b/drools-metric/src/main/java/org/drools/metric/phreak/PhreakExistsNodeMetric.java index 04f26d48e93..f7f8c130b91 100644 --- a/drools-metric/src/main/java/org/drools/metric/phreak/PhreakExistsNodeMetric.java +++ b/drools-metric/src/main/java/org/drools/metric/phreak/PhreakExistsNodeMetric.java @@ -21,9 +21,8 @@ import org.drools.core.common.ReteEvaluator; import org.drools.core.common.TupleSets; import org.drools.core.phreak.PhreakExistsNode; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.ExistsNode; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; import org.drools.metric.util.MetricLogUtils; @@ -32,7 +31,7 @@ public class PhreakExistsNodeMetric extends PhreakExistsNode { @Override public void doNode(ExistsNode existsNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, diff --git a/drools-metric/src/main/java/org/drools/metric/phreak/PhreakJoinNodeMetric.java b/drools-metric/src/main/java/org/drools/metric/phreak/PhreakJoinNodeMetric.java index 2cd19bebf3a..e8f45d7384a 100644 --- a/drools-metric/src/main/java/org/drools/metric/phreak/PhreakJoinNodeMetric.java +++ b/drools-metric/src/main/java/org/drools/metric/phreak/PhreakJoinNodeMetric.java @@ -21,9 +21,8 @@ import org.drools.core.common.ReteEvaluator; import org.drools.core.common.TupleSets; import org.drools.core.phreak.PhreakJoinNode; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.JoinNode; -import org.drools.core.reteoo.LeftTuple; import org.drools.core.reteoo.LeftTupleSink; import org.drools.metric.util.MetricLogUtils; @@ -32,7 +31,7 @@ public class PhreakJoinNodeMetric extends PhreakJoinNode { @Override public void doNode(JoinNode joinNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, diff --git a/drools-metric/src/main/java/org/drools/metric/phreak/PhreakNotNodeMetric.java b/drools-metric/src/main/java/org/drools/metric/phreak/PhreakNotNodeMetric.java index 30fe71d2690..894b593beee 100644 --- a/drools-metric/src/main/java/org/drools/metric/phreak/PhreakNotNodeMetric.java +++ b/drools-metric/src/main/java/org/drools/metric/phreak/PhreakNotNodeMetric.java @@ -21,8 +21,7 @@ import org.drools.core.common.ReteEvaluator; import org.drools.core.common.TupleSets; import org.drools.core.phreak.PhreakNotNode; -import org.drools.core.reteoo.BetaMemoryImpl; -import org.drools.core.reteoo.LeftTuple; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.LeftTupleSink; import org.drools.core.reteoo.NotNode; import org.drools.metric.util.MetricLogUtils; @@ -32,7 +31,7 @@ public class PhreakNotNodeMetric extends PhreakNotNode { @Override public void doNode(NotNode notNode, LeftTupleSink sink, - BetaMemoryImpl bm, + BetaMemory bm, ReteEvaluator reteEvaluator, TupleSets srcLeftTuples, TupleSets trgLeftTuples, diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java index dc7c7fe22d4..ecee4e74f76 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/compiler/MemoryLeakTest.java @@ -36,7 +36,6 @@ import org.drools.core.impl.InternalRuleBase; import org.drools.core.reteoo.AlphaNode; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftInputAdapterNode; import org.drools.core.reteoo.ObjectTypeNode; @@ -120,7 +119,7 @@ public void testStagedTupleLeak() throws Exception { assertThat(joinNode).isNotNull(); InternalWorkingMemory wm = (InternalWorkingMemory) ksession; - BetaMemoryImpl memory = (BetaMemoryImpl) wm.getNodeMemory(joinNode); + BetaMemory memory = (BetaMemory) wm.getNodeMemory(joinNode); TupleSets stagedRightTuples = memory.getStagedRightTuples(); assertThat(stagedRightTuples.getDeleteFirst()).isNull(); assertThat(stagedRightTuples.getInsertFirst()).isNull(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java index 6288467b9ff..8630aaffed3 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/LinkingTest.java @@ -28,13 +28,12 @@ import org.drools.core.common.InternalWorkingMemory; import org.drools.core.common.MemoryFactory; import org.drools.core.impl.InternalRuleBase; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.RightInputAdapterNode.RiaPathMemory; import org.drools.kiesession.session.StatefulKnowledgeSessionImpl; import org.drools.core.phreak.RuleAgendaItem; import org.drools.core.phreak.RuleExecutor; import org.drools.core.phreak.RuntimeSegmentUtilities; -import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.EvalConditionNode; import org.drools.core.reteoo.ExistsNode; import org.drools.core.reteoo.JoinNode; @@ -342,9 +341,9 @@ public void testSubNetworkSharingMemories() throws Exception { LiaNodeMemory liam = wm.getNodeMemory(liaNodeA); - BetaMemoryImpl bm1 = (BetaMemoryImpl) wm.getNodeMemory(joinNodeB); - BetaMemoryImpl bm2 = (BetaMemoryImpl) wm.getNodeMemory(joinNodeC); - BetaMemoryImpl bm3 = (BetaMemoryImpl) wm.getNodeMemory(joinNodeD1); + BetaMemory bm1 = (BetaMemory) wm.getNodeMemory(joinNodeB); + BetaMemory bm2 = (BetaMemory) wm.getNodeMemory(joinNodeC); + BetaMemory bm3 = (BetaMemory) wm.getNodeMemory(joinNodeD1); assertThat(liam.getNodePosMaskBit()).isEqualTo(1); assertThat(bm1.getNodePosMaskBit()).isEqualTo(1); assertThat(bm2.getNodePosMaskBit()).isEqualTo(2); @@ -354,8 +353,8 @@ public void testSubNetworkSharingMemories() throws Exception { assertThat(bm2.getSegmentMemory()).isSameAs(bm1.getSegmentMemory()); assertThat(bm3.getSegmentMemory()).isNotSameAs(bm2.getSegmentMemory()); - BetaMemoryImpl bm4 = (BetaMemoryImpl) wm.getNodeMemory(existsNode2); - BetaMemoryImpl bm5 = (BetaMemoryImpl) wm.getNodeMemory(joinNodeD2); + BetaMemory bm4 = (BetaMemory) wm.getNodeMemory(existsNode2); + BetaMemory bm5 = (BetaMemory) wm.getNodeMemory(joinNodeD2); assertThat(bm4.getNodePosMaskBit()).isEqualTo(1); assertThat(bm5.getNodePosMaskBit()).isEqualTo(2); assertThat(bm5.getSegmentMemory()).isSameAs(bm4.getSegmentMemory()); @@ -371,8 +370,8 @@ public void testSubNetworkSharingMemories() throws Exception { wm.insert( new E() ); wm.flushPropagations(); - BetaMemoryImpl bm6 = (BetaMemoryImpl) wm.getNodeMemory(existsNode3); - BetaMemoryImpl bm7 = (BetaMemoryImpl) wm.getNodeMemory(joinNodeE); + BetaMemory bm6 = (BetaMemory) wm.getNodeMemory(existsNode3); + BetaMemory bm7 = (BetaMemory) wm.getNodeMemory(joinNodeE); assertThat(bm6.getNodePosMaskBit()).isEqualTo(1); assertThat(bm7.getNodePosMaskBit()).isEqualTo(2); assertThat(bm7.getSegmentMemory()).isSameAs(bm6.getSegmentMemory()); @@ -431,7 +430,7 @@ public void testSubNetworkRiaLinking() throws Exception { RuleTerminalNode rtn = ( RuleTerminalNode ) eNode.getSinkPropagator().getSinks()[0]; RuntimeSegmentUtilities.getOrCreateSegmentMemory(exists1n, wm); - BetaMemoryImpl existsBm = (BetaMemoryImpl) wm.getNodeMemory(exists1n); + BetaMemory existsBm = (BetaMemory) wm.getNodeMemory(exists1n); assertThat(existsBm.getSegmentMemory().getLinkedNodeMask()).isEqualTo(0); @@ -515,7 +514,7 @@ public void testNonReactiveSubNetworkInShareMasks() throws Exception { assertThat(pmem.getAllLinkedMaskTest()).isEqualTo(7); // D is in the exists segment - BetaMemoryImpl bm = (BetaMemoryImpl) wm.getNodeMemory(dNode); + BetaMemory bm = (BetaMemory) wm.getNodeMemory(dNode); assertThat(bm.getSegmentMemory()).isNull(); // check lazy initialization wm.insert(new X()); wm.flushPropagations(); @@ -712,14 +711,14 @@ public void testNestedSubNetworkMasks() throws Exception { wm.flushPropagations(); LiaNodeMemory liaMem = wm.getNodeMemory(liaNode); - BetaMemoryImpl bMem = (BetaMemoryImpl) wm.getNodeMemory(bNode); - BetaMemoryImpl exists1Mem = (BetaMemoryImpl) wm.getNodeMemory(exists1n); - BetaMemoryImpl cMem = (BetaMemoryImpl) wm.getNodeMemory(cNode); - BetaMemoryImpl dMem = (BetaMemoryImpl) wm.getNodeMemory(dNode); - BetaMemoryImpl exists2Mem = (BetaMemoryImpl) wm.getNodeMemory(exists2n); - BetaMemoryImpl eMem = (BetaMemoryImpl) wm.getNodeMemory(eNode); - BetaMemoryImpl fMem = (BetaMemoryImpl) wm.getNodeMemory(fNode); - BetaMemoryImpl gMem = (BetaMemoryImpl) wm.getNodeMemory(gNode); + BetaMemory bMem = (BetaMemory) wm.getNodeMemory(bNode); + BetaMemory exists1Mem = (BetaMemory) wm.getNodeMemory(exists1n); + BetaMemory cMem = (BetaMemory) wm.getNodeMemory(cNode); + BetaMemory dMem = (BetaMemory) wm.getNodeMemory(dNode); + BetaMemory exists2Mem = (BetaMemory) wm.getNodeMemory(exists2n); + BetaMemory eMem = (BetaMemory) wm.getNodeMemory(eNode); + BetaMemory fMem = (BetaMemory) wm.getNodeMemory(fNode); + BetaMemory gMem = (BetaMemory) wm.getNodeMemory(gNode); RiaPathMemory riaMem1 = (RiaPathMemory) wm.getNodeMemory(riaNode1); RiaPathMemory riaMem2 = (RiaPathMemory) wm.getNodeMemory(riaNode2); @@ -875,8 +874,8 @@ public void testJoinNodes() throws Exception { JoinNode cNode = ( JoinNode) bNode.getSinkPropagator().getSinks()[0]; LiaNodeMemory amem = wm.getNodeMemory(aNode); - BetaMemoryImpl bmem = (BetaMemoryImpl) wm.getNodeMemory(bNode); - BetaMemoryImpl cmem = (BetaMemoryImpl) wm.getNodeMemory(cNode); + BetaMemory bmem = (BetaMemory) wm.getNodeMemory(bNode); + BetaMemory cmem = (BetaMemory) wm.getNodeMemory(cNode); // amem.getSegmentMemory().getStagedLeftTuples().insertSize() == 3 assertThat(amem.getSegmentMemory().getStagedLeftTuples().getInsertFirst()).isNotNull(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java index ca78d956fda..ba9601a8ffc 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/PhreakConcurrencyTest.java @@ -30,7 +30,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.kiesession.entrypoints.NamedEntryPoint; import org.drools.core.common.ReteEvaluator; import org.drools.core.reteoo.AlphaNode; @@ -400,7 +400,7 @@ public Boolean call() throws Exception { ObjectTypeNode otn = ((NamedEntryPoint)ep).getEntryPointNode().getObjectTypeNodes().values().iterator().next(); AlphaNode alpha = (AlphaNode)otn.getObjectSinkPropagator().getSinks()[0]; BetaNode beta = (BetaNode)alpha.getObjectSinkPropagator().getSinks()[0]; - BetaMemoryImpl memory = (BetaMemoryImpl) reteEvaluator.getNodeMemory(beta); + BetaMemory memory = (BetaMemory) reteEvaluator.getNodeMemory(beta); memory.getSegmentMemory(); for (int i = 0; i < 100; i++) { diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java index c984d3efde1..0e88c104d1f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/SegmentCreationTest.java @@ -26,7 +26,7 @@ import org.drools.core.common.InternalWorkingMemory; import org.drools.core.impl.InternalRuleBase; import org.drools.core.phreak.PhreakBuilder; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.ConditionalBranchNode; import org.drools.base.reteoo.InitialFactImpl; import org.drools.core.reteoo.JoinNode; @@ -203,7 +203,7 @@ public void testMultiSharedPattern() throws Exception { wm.flushPropagations(); // LiaNode is in it's own segment - BetaMemoryImpl betaMem = (BetaMemoryImpl) wm.getNodeMemory(beta); + BetaMemory betaMem = (BetaMemory) wm.getNodeMemory(beta); SegmentMemory smem = betaMem.getSegmentMemory(); assertThat(smem.getRootNode()).isEqualTo(lian); assertThat(smem.getTipNode()).isEqualTo(beta); @@ -269,7 +269,7 @@ public void testSubnetworkNoSharing() throws Exception { assertThat(bSmem.getRootNode()).isEqualTo(bNode); assertThat(bSmem.getTipNode()).isEqualTo(riaNode); - BetaMemoryImpl bm = (BetaMemoryImpl) wm.getNodeMemory(notNode); + BetaMemory bm = (BetaMemory) wm.getNodeMemory(notNode); assertThat(smem.getNext()).isEqualTo(bm.getSegmentMemory()); assertThat(bm.getRiaRuleMemory().getSegmentMemory()).isEqualTo(bSmem); // check subnetwork ref was made } @@ -303,7 +303,7 @@ public void tesSubnetworkAfterShare() throws Exception { wm.insert( new LinkingTest.C() ); wm.fireAllRules(); - BetaMemoryImpl liaMem = (BetaMemoryImpl) wm.getNodeMemory(joinNode); + BetaMemory liaMem = (BetaMemory) wm.getNodeMemory(joinNode); SegmentMemory smem = liaMem.getSegmentMemory(); assertThat(smem.getRootNode()).isEqualTo(lian); assertThat(smem.getTipNode()).isEqualTo(joinNode); @@ -461,7 +461,7 @@ public void testBranchCEMultipleSegments() throws Exception { FactHandle cFh = wm.insert( new LinkingTest.C() ); wm.flushPropagations(); - BetaMemoryImpl bNodeBm = (BetaMemoryImpl) wm.getNodeMemory(bNode); + BetaMemory bNodeBm = (BetaMemory) wm.getNodeMemory(bNode); SegmentMemory bNodeSmem = bNodeBm.getSegmentMemory(); assertThat(bNodeSmem.getAllLinkedMaskTest()).isEqualTo(0); // no beta nodes before branch CE, so never unlinks assertThat(bNodeSmem.getLinkedNodeMask()).isEqualTo(2); @@ -477,7 +477,7 @@ public void testBranchCEMultipleSegments() throws Exception { assertThat(pmemr3.getSegmentMemories().length).isEqualTo(3); assertThat(pmemr3.isRuleLinked()).isFalse(); - BetaMemoryImpl cNodeBm = (BetaMemoryImpl) wm.getNodeMemory(cNode); + BetaMemory cNodeBm = (BetaMemory) wm.getNodeMemory(cNode); SegmentMemory cNodeSmem = cNodeBm.getSegmentMemory(); assertThat(cNodeSmem.getAllLinkedMaskTest()).isEqualTo(PhreakBuilder.isEagerSegmentCreation() ? 0 : 1); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java index 8409e74b307..e0b5bf652b8 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/AddRuleTest.java @@ -37,7 +37,7 @@ import org.drools.core.phreak.EagerPhreakBuilder.Add; import org.drools.core.phreak.EagerPhreakBuilder.Pair; import org.drools.core.phreak.PhreakBuilder; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.BetaNode; import org.drools.core.reteoo.EvalConditionNode; import org.drools.core.reteoo.ExistsNode; @@ -663,12 +663,12 @@ public void testPopulatedRuleMidwayShare() throws Exception { LiaNodeMemory lm = wm.getNodeMemory(liaNode); SegmentMemory sm = lm.getSegmentMemory(); - BetaMemoryImpl c1Mem = (BetaMemoryImpl) wm.getNodeMemory(c1Node); + BetaMemory c1Mem = (BetaMemory) wm.getNodeMemory(c1Node); assertThat(c1Mem.getSegmentMemory()).isSameAs(sm.getFirst()); assertThat(c1Mem.getLeftTupleMemory().size()).isEqualTo(3); assertThat(c1Mem.getRightTupleMemory().size()).isEqualTo(1); - BetaMemoryImpl c2Mem = (BetaMemoryImpl) wm.getNodeMemory(c2Node); + BetaMemory c2Mem = (BetaMemory) wm.getNodeMemory(c2Node); SegmentMemory c2Smem = sm.getFirst().getNext(); assertThat(c2Mem.getSegmentMemory()).isSameAs(c2Smem); assertThat(c2Mem.getLeftTupleMemory().size()).isEqualTo(0); @@ -727,12 +727,12 @@ public void testPopulatedRuleWithEvals() throws Exception { LiaNodeMemory lm = wm.getNodeMemory(liaNode); SegmentMemory sm = lm.getSegmentMemory(); - BetaMemoryImpl c1Mem = (BetaMemoryImpl) wm.getNodeMemory(c1Node); + BetaMemory c1Mem = (BetaMemory) wm.getNodeMemory(c1Node); assertThat(c1Mem.getSegmentMemory()).isSameAs(sm.getFirst()); assertThat(c1Mem.getLeftTupleMemory().size()).isEqualTo(3); assertThat(c1Mem.getRightTupleMemory().size()).isEqualTo(1); - BetaMemoryImpl c2Mem = (BetaMemoryImpl) wm.getNodeMemory(c2Node); + BetaMemory c2Mem = (BetaMemory) wm.getNodeMemory(c2Node); SegmentMemory c2Smem = sm.getFirst().getNext(); assertThat(c2Mem.getSegmentMemory()).isSameAs(c2Smem); assertThat(c2Mem.getLeftTupleMemory().size()).isEqualTo(0); @@ -785,7 +785,7 @@ public void testPopulatedSharedLiaNode() throws Exception { JoinNode bNode1 = (JoinNode) liaNode.getSinkPropagator().getFirstLeftTupleSink(); JoinNode bNode2 = (JoinNode) liaNode.getSinkPropagator().getLastLeftTupleSink(); - BetaMemoryImpl bm = (BetaMemoryImpl) wm.getNodeMemory(bNode2); + BetaMemory bm = (BetaMemory) wm.getNodeMemory(bNode2); SegmentMemory sm = bm.getSegmentMemory(); assertThat(sm.getStagedLeftTuples().getInsertFirst()).isNotNull(); assertThat((Tuple) sm.getStagedLeftTuples().getInsertFirst().getStagedNext()).isNotNull(); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java index cedb57fa722..ae302e8a87f 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakJoinNodeTest.java @@ -27,7 +27,7 @@ import org.drools.core.impl.KnowledgeBaseImpl; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.phreak.PhreakJoinNode; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.CoreComponentFactory; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftTupleNode; @@ -50,10 +50,10 @@ public class PhreakJoinNodeTest { JoinNode joinNode; JoinNode sinkNode; InternalWorkingMemory wm; - BetaMemoryImpl bm; + BetaMemory bm; SegmentMemory smem; - BetaMemoryImpl bm0; + BetaMemory bm0; SegmentMemory smem0; public void setupJoinNode() { @@ -78,9 +78,9 @@ public void setupJoinNode() { wm = (InternalWorkingMemory) KnowledgeBaseFactory.newKnowledgeBase(buildContext.getRuleBase()).newKieSession(); - bm = (BetaMemoryImpl) wm.getNodeMemory(joinNode); + bm = (BetaMemory) wm.getNodeMemory(joinNode); - bm0 =(BetaMemoryImpl) wm.getNodeMemory(sinkNode); + bm0 =(BetaMemory) wm.getNodeMemory(sinkNode); smem = proto1.newSegmentMemory(wm); bm.setSegmentMemory( smem ); @@ -227,7 +227,7 @@ private Scenario test() { private Scenario test(Class phreakNode, JoinNode joinNode, LeftTupleSink sinkNode, - BetaMemoryImpl bm, + BetaMemory bm, InternalWorkingMemory wm) { return new Scenario( phreakNode, joinNode, sinkNode, bm, wm ); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java index f06e169b8ea..6893b15caf6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/PhreakNotNodeTest.java @@ -26,7 +26,7 @@ import org.drools.core.impl.KnowledgeBaseImpl; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.phreak.PhreakNotNode; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.CoreComponentFactory; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftTupleNode; @@ -52,7 +52,7 @@ public class PhreakNotNodeTest { NotNode notNode; JoinNode sinkNode; InternalWorkingMemory wm; - BetaMemoryImpl bm; + BetaMemory bm; private void setupNotNode(String operator) { buildContext = createContext(); @@ -76,9 +76,9 @@ private void setupNotNode(String operator) { wm = (InternalWorkingMemory) KnowledgeBaseFactory.newKnowledgeBase(buildContext.getRuleBase()).newKieSession(); - bm =(BetaMemoryImpl) wm.getNodeMemory(notNode); + bm =(BetaMemory) wm.getNodeMemory(notNode); - BetaMemoryImpl bm1 =(BetaMemoryImpl) wm.getNodeMemory(sinkNode); + BetaMemory bm1 =(BetaMemory) wm.getNodeMemory(sinkNode); SegmentMemory smem = proto1.newSegmentMemory(wm); bm.setSegmentMemory( smem ); @@ -151,7 +151,7 @@ private Scenario test() { private Scenario test(NotNode notNode, LeftTupleSink sinkNode, - BetaMemoryImpl bm, + BetaMemory bm, InternalWorkingMemory wm) { return new Scenario( PhreakNotNode.class, notNode, sinkNode, bm, wm ) ; } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java index 8e5edeff6ad..d7be71f427d 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/RemoveRuleTest.java @@ -24,7 +24,6 @@ import org.drools.core.common.NodeMemories; import org.drools.core.impl.InternalRuleBase; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.EvalConditionNode; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftInputAdapterNode; @@ -188,12 +187,12 @@ public void testPopulatedRuleMidwayShare() throws Exception { LiaNodeMemory lm = wm.getNodeMemory(liaNode); SegmentMemory sm = lm.getSegmentMemory(); - BetaMemoryImpl c1Mem = (BetaMemoryImpl) wm.getNodeMemory(c1Node); + BetaMemory c1Mem = (BetaMemory) wm.getNodeMemory(c1Node); assertThat(c1Mem.getSegmentMemory()).isSameAs(sm.getFirst()); assertThat(c1Mem.getLeftTupleMemory().size()).isEqualTo(3); assertThat(c1Mem.getRightTupleMemory().size()).isEqualTo(1); - BetaMemoryImpl c2Mem = (BetaMemoryImpl) wm.getNodeMemory(c2Node); + BetaMemory c2Mem = (BetaMemory) wm.getNodeMemory(c2Node); SegmentMemory c2Smem = sm.getFirst().getNext(); assertThat(c2Mem.getSegmentMemory()).isSameAs(c2Smem); assertThat(c2Mem.getLeftTupleMemory().size()).isEqualTo(3); @@ -251,12 +250,12 @@ public void testPopulatedRuleWithEvals() throws Exception { LiaNodeMemory lm = wm.getNodeMemory(liaNode); SegmentMemory sm = lm.getSegmentMemory(); - BetaMemoryImpl c1Mem = (BetaMemoryImpl) wm.getNodeMemory(c1Node); + BetaMemory c1Mem = (BetaMemory) wm.getNodeMemory(c1Node); assertThat(c1Mem.getSegmentMemory()).isSameAs(sm.getFirst()); assertThat(c1Mem.getLeftTupleMemory().size()).isEqualTo(3); assertThat(c1Mem.getRightTupleMemory().size()).isEqualTo(1); - BetaMemoryImpl c2Mem = (BetaMemoryImpl) wm.getNodeMemory(c2Node); + BetaMemory c2Mem = (BetaMemory) wm.getNodeMemory(c2Node); SegmentMemory c2Smem = sm.getFirst().getNext(); assertThat(c2Mem.getSegmentMemory()).isSameAs(c2Smem); assertThat(c2Mem.getLeftTupleMemory().size()).isEqualTo(3); @@ -311,19 +310,19 @@ public void testPopulatedSharedLiaNode() throws Exception { LiaNodeMemory lm = wm.getNodeMemory(liaNode); SegmentMemory sm = lm.getSegmentMemory(); - BetaMemoryImpl b1Mem = (BetaMemoryImpl) wm.getNodeMemory(b1Node); + BetaMemory b1Mem = (BetaMemory) wm.getNodeMemory(b1Node); assertThat(b1Mem.getSegmentMemory()).isSameAs(sm.getFirst()); assertThat(b1Mem.getLeftTupleMemory().size()).isEqualTo(3); assertThat(b1Mem.getRightTupleMemory().size()).isEqualTo(1); - BetaMemoryImpl b2Mem = (BetaMemoryImpl) wm.getNodeMemory(b2Node); + BetaMemory b2Mem = (BetaMemory) wm.getNodeMemory(b2Node); SegmentMemory b2Smem = sm.getFirst().getNext(); assertThat(b2Mem.getSegmentMemory()).isSameAs(b2Smem); assertThat(b2Mem.getLeftTupleMemory().size()).isEqualTo(3); assertThat(b2Mem.getRightTupleMemory().size()).isEqualTo(1); assertThat(list.size()).isEqualTo(6); - BetaMemoryImpl c1Mem = (BetaMemoryImpl) wm.getNodeMemory(c1Node); + BetaMemory c1Mem = (BetaMemory) wm.getNodeMemory(c1Node); assertThat(c1Mem.getSegmentMemory()).isSameAs(b1Mem.getSegmentMemory()); assertThat(b2Mem.getSegmentMemory()).isNotSameAs(b1Mem.getSegmentMemory()); diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/Scenario.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/Scenario.java index 7f848d67666..c5c237e7ddc 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/Scenario.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/Scenario.java @@ -26,7 +26,6 @@ import org.drools.core.phreak.PhreakNotNode; import org.drools.core.phreak.SegmentPropagator; import org.drools.core.reteoo.BetaMemory; -import org.drools.core.reteoo.BetaMemoryImpl; import org.drools.core.reteoo.BetaNode; import org.drools.core.reteoo.ExistsNode; import org.drools.core.reteoo.JoinNode; @@ -51,7 +50,7 @@ public class Scenario { Class phreakNode; BetaNode betaNode; LeftTupleSink sinkNode; - BetaMemoryImpl bm; + BetaMemory bm; InternalWorkingMemory wm; TupleSets leftTuples; @@ -75,7 +74,7 @@ public class Scenario { public Scenario(Class phreakNode, BetaNode betaNode, LeftTupleSink sinkNode, - BetaMemoryImpl bm, + BetaMemory bm, InternalWorkingMemory wm) { this.phreakNode = phreakNode; this.betaNode = betaNode; diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java index 4f13c8e4f7b..16b3650d6a6 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/ScenarioTest.java @@ -26,7 +26,7 @@ import org.drools.core.impl.KnowledgeBaseImpl; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.phreak.PhreakJoinNode; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.CoreComponentFactory; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftTupleNode; @@ -52,10 +52,10 @@ public class ScenarioTest { JoinNode joinNode; JoinNode sinkNode; InternalWorkingMemory wm; - BetaMemoryImpl bm; + BetaMemory bm; SegmentMemory smem; - BetaMemoryImpl bm0; + BetaMemory bm0; SegmentMemory smem0; public void setupJoinNode() { @@ -80,9 +80,9 @@ public void setupJoinNode() { wm = (InternalWorkingMemory) KnowledgeBaseFactory.newKnowledgeBase(buildContext.getRuleBase()).newKieSession(); - bm =(BetaMemoryImpl) wm.getNodeMemory(joinNode); + bm =(BetaMemory) wm.getNodeMemory(joinNode); - bm0 =(BetaMemoryImpl) wm.getNodeMemory(sinkNode); + bm0 =(BetaMemory) wm.getNodeMemory(sinkNode); smem = proto1.newSegmentMemory(wm); bm.setSegmentMemory( smem ); @@ -746,7 +746,7 @@ private Scenario test() { private Scenario test(Class phreakNode, JoinNode joinNode, LeftTupleSink sinkNode, - BetaMemoryImpl bm, + BetaMemory bm, InternalWorkingMemory wm) { return new Scenario( phreakNode, joinNode, sinkNode, bm, wm ); } diff --git a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java index c1268447a30..af39809bc01 100644 --- a/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java +++ b/drools-test-coverage/test-compiler-integration/src/test/java/org/drools/mvel/integrationtests/phreak/SegmentPropagationTest.java @@ -26,7 +26,7 @@ import org.drools.core.impl.KnowledgeBaseImpl; import org.drools.core.impl.RuleBaseFactory; import org.drools.core.phreak.PhreakJoinNode; -import org.drools.core.reteoo.BetaMemoryImpl; +import org.drools.core.reteoo.BetaMemory; import org.drools.core.reteoo.CoreComponentFactory; import org.drools.core.reteoo.JoinNode; import org.drools.core.reteoo.LeftTupleNode; @@ -53,12 +53,12 @@ public class SegmentPropagationTest { JoinNode sinkNode2; InternalWorkingMemory wm; - BetaMemoryImpl bm; + BetaMemory bm; SegmentMemory smem; - BetaMemoryImpl bm0; - BetaMemoryImpl bm1; - BetaMemoryImpl bm2; + BetaMemory bm0; + BetaMemory bm1; + BetaMemory bm2; SegmentMemory smem0; SegmentMemory smem1; @@ -98,11 +98,11 @@ public void setupJoinNode() { wm = (InternalWorkingMemory) KnowledgeBaseFactory.newKnowledgeBase(buildContext.getRuleBase()).newKieSession();; - bm =(BetaMemoryImpl) wm.getNodeMemory(joinNode); + bm =(BetaMemory) wm.getNodeMemory(joinNode); - bm0 =(BetaMemoryImpl) wm.getNodeMemory(sinkNode0); - bm1 =(BetaMemoryImpl) wm.getNodeMemory(sinkNode1); - bm2 =(BetaMemoryImpl) wm.getNodeMemory(sinkNode2); + bm0 =(BetaMemory) wm.getNodeMemory(sinkNode0); + bm1 =(BetaMemory) wm.getNodeMemory(sinkNode1); + bm2 =(BetaMemory) wm.getNodeMemory(sinkNode2); smem = proto1.newSegmentMemory(wm); bm.setSegmentMemory( smem ); @@ -216,7 +216,7 @@ private Scenario test() { private Scenario test(Class phreakNode, JoinNode joinNode, LeftTupleSink sinkNode, - BetaMemoryImpl bm, + BetaMemory bm, InternalWorkingMemory wm) { return new Scenario( phreakNode, joinNode, sinkNode, bm, wm ) ; }