[jboss-svn-commits] JBL Code SVN: r30915 - in labs/jbossrules/branches/true_modify_20100104/drools-core/src: test/java/org/drools/reteoo/test and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jan 4 17:02:35 EST 2010
Author: mark.proctor at jboss.com
Date: 2010-01-04 17:02:34 -0500 (Mon, 04 Jan 2010)
New Revision: 30915
Added:
labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/ModifyPreviousTuples.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeAssertRetractTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeIndexTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeModifyTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ForallNodeAssertRetractTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeAssertRetractTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeIndexTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeModifyTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeAssertRetractTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeIndexTest.data
labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeModifyTest.data
Log:
JBRULES-2240 true modify
-initial true modify commit, working for not, exists and join. works for manners and waltz
JBRULES-2339 Rete DSL test harness
-Added support for new nodes (need to merge into trunk still)
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/ModifyPreviousTuples.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/ModifyPreviousTuples.java (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/main/java/org/drools/reteoo/ModifyPreviousTuples.java 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,117 @@
+package org.drools.reteoo;
+
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.drools.common.InternalWorkingMemory;
+import org.drools.spi.PropagationContext;
+
+public class ModifyPreviousTuples {
+ private LeftTuple leftTuple;
+ private RightTuple rightTuple;
+
+ private Map<RightTupleSink, RightTuple> rightTuples;
+ private Map<LeftTupleSink, LeftTuple> leftTuples;
+
+ public ModifyPreviousTuples(LeftTuple leftTuple,
+ RightTuple rightTuple) {
+ this.leftTuple = leftTuple;
+ this.rightTuple = rightTuple;
+ }
+
+ public Map<RightTupleSink, RightTuple> getRightTuples() {
+ return rightTuples;
+ }
+
+ public void setRightTuples(Map<RightTupleSink, RightTuple> rightTuples) {
+ this.rightTuples = rightTuples;
+ }
+
+ public Map<LeftTupleSink, LeftTuple> getLeftTuples() {
+ return leftTuples;
+ }
+
+ public void setLeftTuples(Map<LeftTupleSink, LeftTuple> leftTuples) {
+ this.leftTuples = leftTuples;
+ }
+
+ public LeftTuple removeLeftTuple(LeftTupleSink sink) {
+ if ( this.leftTuple == null ) {
+ return null;
+ }
+ if ( this.leftTuples == null ) {
+ if ( this.leftTuple.getLeftTupleSink() == sink ) {
+ LeftTuple current = this.leftTuple;
+ current.setLeftParentPrevious( null );
+ this.leftTuple = current.getLeftParentNext();
+ current.setLeftParentNext( null );
+ return current;
+ } else {
+ this.leftTuples = new IdentityHashMap<LeftTupleSink, LeftTuple>();
+ for ( ; leftTuple != null; leftTuple = (LeftTuple) leftTuple.getLeftParentNext() ) {
+ this.leftTuples.put( leftTuple.getLeftTupleSink(),
+ leftTuple );
+ }
+ }
+ }
+ return this.leftTuples.remove( sink );
+ }
+
+ public RightTuple removeRightTuple(RightTupleSink sink) {
+ if ( this.rightTuple == null ) {
+ return null;
+ }
+ if ( this.rightTuples == null ) {
+ if ( this.rightTuple.getRightTupleSink() == sink ) {
+ RightTuple current = this.rightTuple;
+ current.setHandlePrevious( null );
+ this.rightTuple = current.getHandleNext();
+ current.setHandleNext( null );
+
+ return current;
+ } else {
+ this.rightTuples = new IdentityHashMap<RightTupleSink, RightTuple>();
+ for ( ; rightTuple != null; rightTuple = (RightTuple) rightTuple.getHandleNext() ) {
+ this.rightTuples.put( rightTuple.getRightTupleSink(),
+ rightTuple );
+ }
+ }
+ }
+ return this.rightTuples.remove( sink );
+ }
+
+ public void retractTuples(PropagationContext context,
+ InternalWorkingMemory workingMemory) {
+ // retract any remaining LeftTuples
+ if ( this.leftTuples == null ) {
+ for ( LeftTuple current = this.leftTuple; current != null; current = (LeftTuple) current.getLeftParentNext() ) {
+ current.getLeftTupleSink().retractLeftTuple( current,
+ context,
+ workingMemory );
+ }
+ } else {
+ for ( Entry<LeftTupleSink, LeftTuple> entry : this.leftTuples.entrySet() ) {
+ entry.getKey().retractLeftTuple( entry.getValue(),
+ context,
+ workingMemory );
+ }
+ }
+
+ // retract any remaining RightTuples
+ if (this.rightTuples == null ) {
+ for ( RightTuple current = this.rightTuple; current != null; current = (RightTuple) current.getHandleNext() ) {
+ current.getRightTupleSink().retractRightTuple( current,
+ context,
+ workingMemory );
+ }
+ } else {
+ for ( Entry<RightTupleSink, RightTuple> entry : this.rightTuples.entrySet() ) {
+ entry.getKey().retractRightTuple( entry.getValue(),
+ context,
+ workingMemory );
+ }
+ }
+ }
+
+}
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/ExistsNodeTest.java 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,91 @@
+package org.drools.reteoo.test;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.SequenceInputStream;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.drools.reteoo.test.ReteDslTestEngine.DslStep;
+
+public class ExistsNodeTest extends TestCase {
+
+ public void testAssertRetract() {
+ executeDsl( "ExistsNodeAssertRetractTest.data" );
+ }
+
+ public void testModify() {
+ executeDsl( "ExistsNodeModifyTest.data" );
+ }
+
+ public void testindex() {
+ executeDsl( "ExistsNodeIndexTest.data" );
+ }
+
+ /*
+ public void testIndexedAssert() {
+ executeDsl( "JoinNodeIndexedAssertTest.data" );
+ }
+
+ public void testIndexedAssertRetract() {
+ executeDsl( new String[]{"JoinNodeIndexedAssertTest.data",
+ "JoinNodeIndexedAssertRetractTest.data"} );
+ }
+
+ public void testIndexedAssertRetractModify() {
+ executeDsl( new String[]{"JoinNodeIndexedAssertTest.data",
+ "JoinNodeIndexedAssertRetractTest.data",
+ "JoinNodeIndexedAssertRetractModifyTest.data"} );
+ }
+
+ public void testNotIndexedAssert() {
+ executeDsl( "JoinNodeNotIndexedAssertTest.data" );
+ }
+
+ public void testNotIndexedAssertRetract() {
+ executeDsl( new String[]{"JoinNodeNotIndexedAssertTest.data",
+ "JoinNodeNotIndexedAssertRetractTest.data"} );
+ }
+
+ public void testNotIndexedAssertRetractModify() {
+ executeDsl( new String[]{"JoinNodeNotIndexedAssertTest.data",
+ "JoinNodeNotIndexedAssertRetractTest.data",
+ "JoinNodeNotIndexedAssertRetractModifyTest.data"} );
+ }
+
+ */
+ public void executeDsl(String[] strings) {
+ InputStream[] inputStreams = new InputStream[strings.length];
+ for ( int i = 0; i < strings.length; i++ ) {
+ inputStreams[i] = getClass().getResourceAsStream( strings[i] );
+ assertNotNull( strings[i], inputStreams[i] );
+ }
+ executeDsl( inputStreams );
+ }
+
+ public void executeDsl(InputStream[] inputStreams) {
+ InputStream inputStream = inputStreams[0];
+
+ for ( int i = 1; i < inputStreams.length; i++ ) {
+ assertNotNull( inputStreams[i] );
+ inputStream = new SequenceInputStream( inputStream,
+ inputStreams[i] );
+ }
+
+ executeDsl( inputStream );
+ }
+
+ public void executeDsl(String string) {
+ executeDsl( getClass().getResourceAsStream( string ) );
+ }
+
+ public void executeDsl(InputStream inputStream) {
+ assertNotNull( inputStream );
+ DslStep[] steps = (DslStep[]) ReteDslTestEngine.buildDslCommands( new InputStreamReader( inputStream ) ).toArray( new DslStep[0] );
+
+ ReteDslTestEngine tester = new ReteDslTestEngine();
+ tester.run( Arrays.asList( steps ) );
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/JoinNodeTest.java 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,91 @@
+package org.drools.reteoo.test;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.SequenceInputStream;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.drools.reteoo.test.ReteDslTestEngine.DslStep;
+
+public class JoinNodeTest extends TestCase {
+
+ public void testAssertRetract() {
+ executeDsl( "JoinNodeAssertRetractTest.data" );
+ }
+
+ public void testModify() {
+ executeDsl( "JoinNodeModifyTest.data" );
+ }
+
+ public void testindex() {
+ executeDsl( "JoinNodeIndexTest.data" );
+ }
+
+ /*
+ public void testIndexedAssert() {
+ executeDsl( "JoinNodeIndexedAssertTest.data" );
+ }
+
+ public void testIndexedAssertRetract() {
+ executeDsl( new String[]{"JoinNodeIndexedAssertTest.data",
+ "JoinNodeIndexedAssertRetractTest.data"} );
+ }
+
+ public void testIndexedAssertRetractModify() {
+ executeDsl( new String[]{"JoinNodeIndexedAssertTest.data",
+ "JoinNodeIndexedAssertRetractTest.data",
+ "JoinNodeIndexedAssertRetractModifyTest.data"} );
+ }
+
+ public void testNotIndexedAssert() {
+ executeDsl( "JoinNodeNotIndexedAssertTest.data" );
+ }
+
+ public void testNotIndexedAssertRetract() {
+ executeDsl( new String[]{"JoinNodeNotIndexedAssertTest.data",
+ "JoinNodeNotIndexedAssertRetractTest.data"} );
+ }
+
+ public void testNotIndexedAssertRetractModify() {
+ executeDsl( new String[]{"JoinNodeNotIndexedAssertTest.data",
+ "JoinNodeNotIndexedAssertRetractTest.data",
+ "JoinNodeNotIndexedAssertRetractModifyTest.data"} );
+ }
+
+ */
+ public void executeDsl(String[] strings) {
+ InputStream[] inputStreams = new InputStream[strings.length];
+ for ( int i = 0; i < strings.length; i++ ) {
+ inputStreams[i] = getClass().getResourceAsStream( strings[i] );
+ assertNotNull( strings[i], inputStreams[i] );
+ }
+ executeDsl( inputStreams );
+ }
+
+ public void executeDsl(InputStream[] inputStreams) {
+ InputStream inputStream = inputStreams[0];
+
+ for ( int i = 1; i < inputStreams.length; i++ ) {
+ assertNotNull( inputStreams[i] );
+ inputStream = new SequenceInputStream( inputStream,
+ inputStreams[i] );
+ }
+
+ executeDsl( inputStream );
+ }
+
+ public void executeDsl(String string) {
+ executeDsl( getClass().getResourceAsStream( string ) );
+ }
+
+ public void executeDsl(InputStream inputStream) {
+ assertNotNull( inputStream );
+ DslStep[] steps = (DslStep[]) ReteDslTestEngine.buildDslCommands( new InputStreamReader( inputStream ) ).toArray( new DslStep[0] );
+
+ ReteDslTestEngine tester = new ReteDslTestEngine();
+ tester.run( Arrays.asList( steps ) );
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/java/org/drools/reteoo/test/NotNodeTest.java 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,91 @@
+package org.drools.reteoo.test;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.SequenceInputStream;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.drools.reteoo.test.ReteDslTestEngine.DslStep;
+
+public class NotNodeTest extends TestCase {
+
+ public void testAssertRetract() {
+ executeDsl( "NotNodeAssertRetractTest.data" );
+ }
+
+ public void testModify() {
+ executeDsl( "NotNodeModifyTest.data" );
+ }
+
+ public void testindex() {
+ executeDsl( "NotNodeIndexTest.data" );
+ }
+
+ /*
+ public void testIndexedAssert() {
+ executeDsl( "JoinNodeIndexedAssertTest.data" );
+ }
+
+ public void testIndexedAssertRetract() {
+ executeDsl( new String[]{"JoinNodeIndexedAssertTest.data",
+ "JoinNodeIndexedAssertRetractTest.data"} );
+ }
+
+ public void testIndexedAssertRetractModify() {
+ executeDsl( new String[]{"JoinNodeIndexedAssertTest.data",
+ "JoinNodeIndexedAssertRetractTest.data",
+ "JoinNodeIndexedAssertRetractModifyTest.data"} );
+ }
+
+ public void testNotIndexedAssert() {
+ executeDsl( "JoinNodeNotIndexedAssertTest.data" );
+ }
+
+ public void testNotIndexedAssertRetract() {
+ executeDsl( new String[]{"JoinNodeNotIndexedAssertTest.data",
+ "JoinNodeNotIndexedAssertRetractTest.data"} );
+ }
+
+ public void testNotIndexedAssertRetractModify() {
+ executeDsl( new String[]{"JoinNodeNotIndexedAssertTest.data",
+ "JoinNodeNotIndexedAssertRetractTest.data",
+ "JoinNodeNotIndexedAssertRetractModifyTest.data"} );
+ }
+
+ */
+ public void executeDsl(String[] strings) {
+ InputStream[] inputStreams = new InputStream[strings.length];
+ for ( int i = 0; i < strings.length; i++ ) {
+ inputStreams[i] = getClass().getResourceAsStream( strings[i] );
+ assertNotNull( strings[i], inputStreams[i] );
+ }
+ executeDsl( inputStreams );
+ }
+
+ public void executeDsl(InputStream[] inputStreams) {
+ InputStream inputStream = inputStreams[0];
+
+ for ( int i = 1; i < inputStreams.length; i++ ) {
+ assertNotNull( inputStreams[i] );
+ inputStream = new SequenceInputStream( inputStream,
+ inputStreams[i] );
+ }
+
+ executeDsl( inputStream );
+ }
+
+ public void executeDsl(String string) {
+ executeDsl( getClass().getResourceAsStream( string ) );
+ }
+
+ public void executeDsl(InputStream inputStream) {
+ assertNotNull( inputStream );
+ DslStep[] steps = (DslStep[]) ReteDslTestEngine.buildDslCommands( new InputStreamReader( inputStream ) ).toArray( new DslStep[0] );
+
+ ReteDslTestEngine tester = new ReteDslTestEngine();
+ tester.run( Arrays.asList( steps ) );
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeAssertRetractTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeAssertRetractTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeAssertRetractTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,154 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian1, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+ExistsNode
+ exists1, lian1, otnRight1
+ age, !=, p1
+JoinNode
+ join2, exists1, otnRight2
+ age, !=, p1
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 35), new org.drools.Person('luke', 35)
+ new org.drools.Person('dave', 35), new org.drools.Person('bob', 36)
+ new org.drools.Person('obi', 36), new org.drools.Person('han', 37)
+
+
+/**
+ * check single left assertion and retraction
+ */
+assert
+ otnLeft1 [h0]
+exists1
+ leftMemory [[h0]]
+join2
+ leftMemory []
+retract
+ otnLeft1 [h0]
+exists1
+ leftMemory []
+join2
+ leftMemory []
+
+/**
+ * check single right assertion and retraction
+ */
+assert
+ otnRight1 [h1]
+exists1
+ rightMemory [h1]
+join2
+ leftMemory []
+retract
+ otnRight1 [h1]
+exists1
+ rightMemory []
+
+/**
+ * check single left then right assertion, where age != age (matches)
+ */
+assert
+ otnLeft1 [h0]
+exists1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory []
+assert
+ otnRight1 [h5] // h5 is not equal, so it blocks, and thus h0 is propagated to join2
+exists1
+ leftMemory []
+ rightMemory [h5]
+join2
+ leftMemory [[h0]]
+retract
+ otnRight1 [h5] // nothing blocks h0, so it's removed from join2
+join2
+ leftMemory []
+retract
+ otnLeft1 [h0]
+exists1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+
+/**
+ * check single right then left assertion, where age != age (matches)
+ */
+assert
+ otnRight1 [h5]
+exists1
+ leftMemory []
+ rightMemory [h5]
+join2
+ leftMemory []
+assert
+ otnLeft1 [h0]
+exists1
+ leftMemory [] // although it's inserted, you can't see it in the memory as h5 blocks it
+ rightMemory [h5]
+join2
+ leftMemory [[h0]]
+retract
+ otnRight1 [h5]
+exists1
+ leftMemory [[h0]] // h5 no longer blocks, so put back in
+ rightMemory []
+join2
+ leftMemory []
+retract
+ otnLeft1 [h0]
+exists1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+
+/**
+ * assert two left and two right, with iterative retract and assert, age != age (not matches)
+ */
+assert
+ otnLeft1 [h0, h1]
+exists1
+ leftMemory [[h0], [h1]]
+ rightMemory []
+join2
+ leftMemory []
+assert
+ otnRight1 [h5]
+exists1
+ leftMemory [] //h0 and h1 are blocked, by h5, so removed
+ rightMemory [h5, h6]
+join2
+ leftMemory [[h0], [h1]]
+assert
+ otnRight1 [h6]
+exists1
+ leftMemory [] //h0 and h1 are still blocked
+ rightMemory [h5, h6]
+join2
+ leftMemory [[h0], [h1]]
+retract
+ otnRight1 [h5] // retract h5, the facts should still be blocked now by h6
+exists1
+ leftMemory [] //h0 and h1 are still blocked
+ rightMemory [h6]
+join2
+ leftMemory [[h0], [h1]]
+retract
+ otnRight1 [h6] // now there are no blockers
+exists1
+ leftMemory [[h0], [h1]] // both facts go back in
+ rightMemory []
+join2
+ leftMemory [] // both facts propagate
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeIndexTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeIndexTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeIndexTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,138 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian1, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+ExistsNode
+ not1, lian1, otnRight1
+ age, ==, p1
+JoinNode
+ join2, not1, otnRight2
+ age, ==, p1
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 35), new org.drools.Person('luke', 35)
+ new org.drools.Person('dave', 35), new org.drools.Person('bob', 36)
+ new org.drools.Person('obi', 36), new org.drools.Person('han', 37)
+
+/**
+ * check single left then right assertion, initially not matched, the toggle matched and unmatched
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory []
+assert
+ otnRight1 [h6]
+not1
+ leftMemory [[h0]]
+ rightMemory [h6]
+join2
+ leftMemory []
+With
+ h6 age = 35
+modify
+ otnRight1 [h6]
+not1
+ leftMemory [] // h0 is removed from here, as it's blocked
+ rightMemory [h6]
+join2
+ leftMemory [[h0]]
+With
+ h6 age = 36
+modify
+ otnRight1 [h6]
+not1
+ leftMemory [[h0]] // h0 is back again, as it's no longer blocked
+ rightMemory [h6]
+join2
+ leftMemory []
+retract
+ otnLeft1 [h0]
+ otnRight1 [h6]
+
+
+
+/**
+ * check two left, two right, initially not matched, toggle various matches.
+ */
+assert
+ otnRight1 [h6]
+ otnLeft1 [h0, h1]
+not1
+ leftMemory [[h0], [h1]]
+ rightMemory [h6]
+join2
+ leftMemory []
+assert
+ otnRight1 [h7]
+With
+ h6 age = 35
+ h7 age = 35
+modify
+ otnRight1 [h6] // h6 now blocks h0 and h1
+not1
+ leftMemory []
+join2
+ leftMemory [[h0], [h1]]
+modify
+ otnRight1 [h7] // now h6 and h7 block, although due to lazy only h6 blocks at the moment
+not1
+ leftMemory []
+join2
+ leftMemory [[h0], [h1]]
+With
+ h1 age = 34
+modify
+ otnLeft1 [h1]
+not1
+ leftMemory [[h1]]
+join2
+ leftMemory [[h0]]
+With
+ h6 age = 34
+ h7 age = 36
+modify
+ otnRight1 [h6, h7] // h6 now blocks h1, h0 is no longer blocked
+not1
+ leftMemory [[h0]]
+join2
+ leftMemory [[h1]]
+retract
+ otnLeft1 [h1]
+With
+ h0 age = 34
+modify
+ otnLeft1 [h0] // h0 should now be blocked by h6
+not1
+ leftMemory []
+join2
+ leftMemory [[h0]]
+With
+ h0 age = 35
+ h1 age = 35
+retract
+ otnLeft1 [h0, h1]
+ otnRight1 [h6, h7]
+
+/**
+ * Test Blocking two, in index, with modify but no index change
+ */
+assert
+ otnRight1 [h3]
+ otnLeft1 [h0, h1]
+not1
+ leftMemory []
+ rightMemory [h3]
+join2
+ leftMemory [[h0], [h1]]
+modify
+ otnRight1 [h3]
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeModifyTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeModifyTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ExistsNodeModifyTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,116 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian1, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+ExistsNode
+ not1, lian1, otnRight1
+ age, !=, p1
+JoinNode
+ join2, not1, otnRight2
+ age, !=, p1
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 35), new org.drools.Person('luke', 35)
+ new org.drools.Person('dave', 35), new org.drools.Person('bob', 36)
+ new org.drools.Person('obi', 36), new org.drools.Person('han', 37)
+
+/**
+ * check single left then right assertion, initially not matched, the toggle matched and unmatched
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory []
+assert
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory []
+With
+ h1 age = 36
+modify
+ otnRight1 [h1]
+not1
+ leftMemory [] // h0 is removed from here, as it's blocked
+ rightMemory [h1]
+join2
+ leftMemory [[h0]]
+With
+ h1 age = 35
+modify
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]] // h0 is back again, as it's no longer blocked
+ rightMemory [h1]
+join2
+ leftMemory []
+retract
+ otnLeft1 [h0]
+ otnRight1 [h1]
+
+
+/**
+ * check two left, two right
+ */
+assert
+ otnRight1 [h6]
+assert
+ otnLeft1 [h0, h1]
+not1
+ leftMemory [] // memory is empty as h0 and h1 are blocked
+join2
+ leftMemory [[h0], [h1]]
+assert
+ otnRight1 [h7]
+With
+ h6 age = 35
+modify
+ otnRight1 [h6] // h7 still blocks h0 and h1
+not1
+ leftMemory []
+join2
+ leftMemory [[h0], [h1]]
+With
+ h7 age = 35
+modify
+ otnRight1 [h7] // h0 and h1 should now be unblocked
+not1
+ leftMemory [[h0], [h1]] // h0 and h1 appear back in memory
+join2
+ leftMemory []
+With
+ h6 age = 36
+modify
+ otnRight1 [h6]
+not1
+ leftMemory [] // h6 blocks both
+join2
+ leftMemory [[h0], [h1]]
+With
+ h0 age = 36
+modify
+ otnLeft1 [h0] // h0 is now blocked by h7, while h1 remains blocked by h6
+not1
+ leftMemory [] // remains empty
+join2
+ leftMemory [[h1], [h0]] // the child order was reversed, because h0 was the last one modified
+With
+ h0 age = 36
+ h7 age = 36
+modify
+ otnLeft1 [h0] // h0 is no longer blocked
+not1
+ leftMemory [[h0]]
+join2
+ leftMemory [[h1]]
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ForallNodeAssertRetractTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ForallNodeAssertRetractTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/ForallNodeAssertRetractTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,223 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian1, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Bus
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, city
+ForAllNode
+ forall1, lian1,
+
+ not1, , otnRight1
+ age, !=, p1
+JoinNode
+ join2, not1, otnRight2
+ age, ==,
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 35), new org.drools.Person('luke', 35)
+ new org.drools.Person('dave', 35), new org.drools.Person('bob', 36)
+ new org.drools.Person('obi', 36), new org.drools.Person('han', 37)
+
+ // Person( $state ) forall( Bus(
+/**
+ * check single left assertion and retraction
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+join2
+ leftMemory []
+
+/**
+ * check single right assertion and retraction
+ */
+assert
+ otnRight1 [h1]
+not1
+ rightMemory [h1]
+join2
+ leftMemory []
+retract
+ otnRight1 [h1]
+not1
+ rightMemory []
+
+/**
+ * check single left then right assertion, where age == age (does not match not)
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory [[h0]]
+assert
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0]]
+retract
+ otnRight1 [h1]
+ otnRight1 []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+/**
+ * check single left then right assertion, where age != age (matches not)
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]] // h0 is here, it'll disapear soon....
+ rightMemory []
+join2
+ leftMemory [[h0]]
+assert
+ otnRight1 [h5]
+not1
+ leftMemory [] // h0 disappears as h5 blocks it, and removes it from memory
+ rightMemory [h5]
+join2
+ leftMemory []
+retract
+ otnRight1 [h5]
+not1
+ leftMemory [[h0]] // h0 is put back in, as h5 no longer blocks
+ rightMemory []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+
+/**
+ * check single right then left assertion, where age != age (matches not)
+ */
+assert
+ otnRight1 [h5]
+not1
+ leftMemory []
+ rightMemory [h5]
+join2
+ leftMemory []
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [] // although it's inserted, you can't see it in the memory as h5 blocks it
+ rightMemory [h5]
+join2
+ leftMemory []
+retract
+ otnRight1 [h5]
+not1
+ leftMemory [[h0]] // h5 no longer blocks, so put back in
+ rightMemory []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+/**
+ * check single right then left assertion, where age == age (does not match not)
+ */
+assert
+ otnRight1 [h1]
+not1
+ leftMemory []
+ rightMemory [h1]
+join2
+ leftMemory []
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0]]
+retract
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+// here
+
+
+/**
+ * assert two left and two right, with iterative retract and assert, age != age (not matches)
+ */
+assert
+ otnLeft1 [h0, h1]
+not1
+ leftMemory [[h0], [h1]]
+ rightMemory []
+join2
+ leftMemory [[h0], [h1]]
+assert
+ otnRight1 [h5]
+not1
+ leftMemory [] //h0 and h1 are blocked, by h5, so removed
+ rightMemory [h5, h6]
+join2
+ leftMemory []
+assert
+ otnRight1 [h6]
+not1
+ leftMemory [] //h0 and h1 are still blocked
+ rightMemory [h5, h6]
+join2
+ leftMemory []
+retract
+ otnRight1 [h5] // retract h5, the facts should still be blocked now by h6
+not1
+ leftMemory [] //h0 and h1 are still blocked
+ rightMemory [h6]
+join2
+ leftMemory []
+retract
+ otnRight1 [h6] // now there are no blockers
+not1
+ leftMemory [[h0], [h1]] // both facts go back in
+ rightMemory []
+join2
+ leftMemory [[h0], [h1]] // both facts propagate
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeAssertRetractTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeAssertRetractTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeAssertRetractTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,206 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian0, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+JoinNode
+ join1, lian0, otnRight1
+ age, !=, p1
+JoinNode
+ join2, join1, otnRight2
+ age, !=, p1
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 36)
+ new org.drools.Person('yoda', 37), new org.drools.Person('luke', 38)
+ new org.drools.Person('dave', 33), new org.drools.Person('bob', 32)
+
+/**
+ * check single left assertion and retraction
+ */
+assert
+ otnLeft1 [h0]
+join1
+ leftMemory [[h0]]
+join2
+ leftMemory []
+retract
+ otnLeft1 [h0]
+/**
+ * check single right assertion and retraction
+ */
+assert
+ otnRight1 [h1]
+join1
+ rightMemory [h1]
+join2
+ leftMemory []
+retract
+ otnRight1 [h1]
+
+/**
+ * check single left then right assertion
+ */
+assert
+ otnLeft1 [h0]
+ otnRight1 [h1]
+join1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0, h1]]
+retract
+ otnLeft1 [h0]
+ otnRight1 [h1]
+
+/**
+ * check single right then left assertion
+ */
+assert
+ otnRight1 [h1]
+ otnLeft1 [h0]
+join1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0, h1]]
+retract
+ otnLeft1 [h0]
+ otnRight1 [h1]
+
+/**
+ * assert two left and two right, with incremental first removal
+ */
+assert
+ otnLeft1 [h0, h1]
+ otnRight1 [h2, h3]
+join1
+ leftMemory [[h0], [h1]]
+ rightMemory [h2, h3]
+join2
+ leftMemory [[h0, h2], [h1, h2],
+ [h0, h3], [h1, h3]]
+retract
+ otnLeft1 [h0]
+join1
+ leftMemory [[h1]]
+ rightMemory [h2, h3]
+join2
+ leftMemory [[h1, h2],
+ [h1, h3]]
+retract
+ otnRight1 [h2]
+join1
+ leftMemory [[h1]]
+ rightMemory [h3]
+join2
+ leftMemory [[h1, h3]]
+retract
+ otnLeft1 [h1]
+ otnRight1 [h3]
+join1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+/**
+ * assert two right and two left, with incremental last removal
+ */
+assert
+ otnRight1 [h2, h3]
+ otnLeft1 [h0, h1]
+join1
+ leftMemory [[h0], [h1]]
+ rightMemory [h2, h3]
+join2
+ leftMemory [[h0, h2], [h0, h3],
+ [h1, h2], [h1, h3]]
+retract
+ otnLeft1 [h1]
+join1
+ leftMemory [[h0]]
+ rightMemory [h2, h3]
+join2
+ leftMemory [[h0, h2], [h0, h3]]
+retract
+ otnRight1 [h3]
+join1
+ leftMemory [[h0]]
+ rightMemory [h2]
+join2
+ leftMemory [[h0, h2]]
+retract
+ otnLeft1 [h0]
+ otnRight1 [h2]
+join1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+/**
+ * assert three left and three right, middle two are removed, and then iterated in reverse order
+ */
+assert
+ otnLeft1 [h0, h5, h2]
+ otnRight1 [h3, h4, h1]
+join1
+ leftMemory [[h0], [h5], [h2]]
+ rightMemory [h3, h4, h1]
+join2
+ leftMemory [[h0, h3], [h5, h3], [h2, h3],
+ [h0, h4], [h5, h4], [h2, h4],
+ [h0, h1], [h5, h1], [h2, h1]]
+ rightMemory []
+retract
+ otnLeft1 [h5]
+join1
+ leftMemory [[h0], [h2]]
+ rightMemory [h3, h4, h1]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4],
+ [h0, h1], [h2, h1]]
+ rightMemory []
+retract
+ otnRight1 [h4]
+join1
+ leftMemory [[h0], [h2]]
+ rightMemory [h3, h1]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h1], [h2, h1]]
+ rightMemory []
+assert
+ otnLeft1 [h5]
+ otnRight1 [h4]
+join1
+ leftMemory [[h0], [h2], [h5]]
+ rightMemory [h3, h1, h4]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h1], [h2, h1],
+ [h5, h3], [h5, h1],
+ [h0, h4], [h2, h4], [h5, h4] ]
+retract
+ otnRight1 [h4]
+join1
+ leftMemory [[h0], [h2], [h5]]
+ rightMemory [h3, h1]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h1], [h2, h1],
+ [h5, h3], [h5, h1] ]
+retract
+ otnLeft1 [h5]
+join1
+ leftMemory [[h0], [h2]]
+ rightMemory [h3, h1]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h1], [h2, h1]]
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeIndexTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeIndexTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeIndexTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,86 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian0, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+JoinNode
+ join1, lian0, otnRight1
+ age, ==, p1
+JoinNode
+ join2, join1, otnRight2
+ age, ==, p1
+Facts
+ new org.drools.Person('darth', 34), new org.drools.Person('bobba', 34)
+ new org.drools.Person('yoda', 34), new org.drools.Person('luke', 34)
+ new org.drools.Person('dave', 34), new org.drools.Person('bob', 34)
+
+
+/**
+ * insert all and the modify for variation combinations, checking the index buckets are obeyed
+ */
+assert
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+join1
+ leftMemory [[h0], [h1], [h2]]
+ rightMemory [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5]]
+
+With
+ h1 age = 35
+modify
+ otnLeft1 [h1]
+join1
+ leftMemory [[h0], [h2] ]
+ leftMemory [[h1]] // h1 has now moved to it's own bucket
+ rightMemory [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4],
+ [h0, h5], [h2, h5] ]
+With
+ h5 age = 36
+modify
+ otnRight1 [h5]
+join1
+ leftMemory [[h0], [h2] ]
+ leftMemory [[h1]] // h1 has now moved to it's own bucket
+ rightMemory [h3, h4]
+ rightMemory [h5] // h5 also now in it's own bucket
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4] ]
+With
+ h5 age = 35
+modify
+ otnRight1 [h5]
+join1
+ leftMemory [[h0], [h2] ]
+ leftMemory [[h1]] // h1 still in it's own bucket
+ rightMemory [h3, h4]
+ rightMemory [h5] // h5 still in it's own bucket
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4] ] // index bucket for age == 34
+ leftMemory [[h1, h5] ] // index bucket for age == 35
+With
+ h0 age = 35
+modify
+ otnLeft1 [h0]
+join1
+ leftMemory [[h2] ]
+ leftMemory [[h1], [h0]] // h0 joins h1 in the 35 index bucket
+ rightMemory [h3, h4]
+ rightMemory [h5] // h5 still in it's own bucket
+join2
+ leftMemory [[h2, h3],
+ [h2, h4] ] // index bucket for age == 34
+ leftMemory [[h1, h5], [h0, h5]] // index bucket for age == 35
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeModifyTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeModifyTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/JoinNodeModifyTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,375 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian0, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+JoinNode
+ join1, lian0, otnRight1
+ age, !=, p1
+JoinNode
+ join2, join1, otnRight2
+ age, !=, p1
+Facts
+ new org.drools.Person('darth', 34), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 36), new org.drools.Person('luke', 37)
+ new org.drools.Person('dave', 38), new org.drools.Person('bob', 39)
+
+/**
+ * insert one left and try modify
+ */
+assert
+ otnLeft1 [h0]
+modify
+ otnLeft1 [h0]
+join1
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+
+/**
+ * insert one right and try modify
+ */
+assert
+ otnRight1 [h1]
+modify
+ otnRight1 [h1]
+join1
+ rightMemory [h1]
+retract
+ otnRight1 [h1]
+
+/**
+ * insert one left and right and try modify, left and right, staying true
+ */
+assert
+ otnLeft1 [h0]
+ otnRight1 [h1]
+join1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0, h1]]
+modify // modifyLeft, should be no change
+ otnLeft1 [h0]
+join1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0, h1]]
+modify // modifyRight, should be no change
+ otnRight1 [h1]
+join1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0, h1]]
+modify // modifyLeft, should be no change
+ otnLeft1 [h0]
+join1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0, h1]]
+retract
+ otnLeft1 [h0]
+ otnRight1 [h1]
+join1
+ leftMemory []
+ rightMemory []
+
+/**
+ * insert all and the modify h0 breaking and re-creating each join, to simulate left modifies
+ */
+assert
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5]]
+With
+ h0 age = 37
+modify
+ otnLeft1 [h0]
+join1
+ leftMemory [[h1], [h2], [h0]] // notice that h0 moves to the end
+join2
+ leftMemory [[h1, h3], [h2, h3],
+ [h1, h4], [h2, h4],
+ [h1, h5], [h2, h5], [h0, h4], [h0, h5] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h0 age = 38
+modify
+ otnLeft1 [h0]
+join1
+ leftMemory [[h1], [h2], [h0]]
+join2
+ leftMemory [[h1, h3], [h2, h3],
+ [h1, h4], [h2, h4],
+ [h1, h5], [h2, h5], [h0, h3], [h0, h5] ]
+With
+ h0 age = 39
+modify
+ otnLeft1 [h0]
+join2
+ leftMemory [[h1, h3], [h2, h3],
+ [h1, h4], [h2, h4],
+ [h1, h5], [h2, h5], [h0, h3], [h0, h4] ]
+With
+ h0 age = 34
+modify
+ otnLeft1 [h0]
+join2
+ leftMemory [[h1, h3], [h2, h3],
+ [h1, h4], [h2, h4],
+ [h1, h5], [h2, h5], [h0, h3], [h0, h4], [h0, h5] ]
+retract
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+
+/**
+ * insert all and the modify h1 breaking and re-creating each join, to simulate left modifies
+ */
+assert
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5]]
+With
+ h1 age = 37
+modify
+ otnLeft1 [h1]
+join1
+ leftMemory [[h0], [h2], [h1]] // notice that h2 moves to the end
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4],
+ [h0, h5], [h2, h5], [h1, h4], [h1, h5] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h1 age = 38
+modify
+ otnLeft1 [h1]
+join1
+ leftMemory [[h0], [h2], [h1]]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4],
+ [h0, h5], [h2, h5], [h1, h3], [h1, h5] ]
+With
+ h1 age = 39
+modify
+ otnLeft1 [h1]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4],
+ [h0, h5], [h2, h5], [h1, h3], [h1, h4] ]
+With
+ h1 age = 35
+modify
+ otnLeft1 [h1]
+join2
+ leftMemory [[h0, h3], [h2, h3],
+ [h0, h4], [h2, h4],
+ [h0, h5], [h2, h5], [h1, h3], [h1, h4], [h1, h5] ]
+retract
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+
+/**
+ * insert all and the modify h2 breaking and re-creating each join, to simulate left modifies
+ */
+assert
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5]]
+With
+ h2 age = 37
+modify
+ otnLeft1 [h2]
+join1
+ leftMemory [[h0], [h1], [h2]] // notice that h3 is still on the end
+join2
+ leftMemory [[h0, h3], [h1, h3],
+ [h0, h4], [h1, h4],
+ [h0, h5], [h1, h5], [h2, h4], [h2, h5] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h2 age = 38
+modify
+ otnLeft1 [h2]
+join1
+ leftMemory [[h0], [h1], [h2]]
+join2
+ leftMemory [[h0, h3], [h1, h3],
+ [h0, h4], [h1, h4],
+ [h0, h5], [h1, h5], [h2, h3], [h2, h5] ]
+With
+ h2 age = 39
+modify
+ otnLeft1 [h2]
+join2
+ leftMemory [[h0, h3], [h1, h3],
+ [h0, h4], [h1, h4],
+ [h0, h5], [h1, h5], [h2, h3], [h2, h4] ]
+With
+ h2 age = 36
+modify
+ otnLeft1 [h2]
+join2
+ leftMemory [[h0, h3], [h1, h3],
+ [h0, h4], [h1, h4],
+ [h0, h5], [h1, h5], [h2, h3], [h2, h4], [h2, h5] ]
+retract
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+
+/**
+ * insert all and the modify h3 breaking and re-creating each join, to simulate right modifies
+ */
+assert
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5]]
+With
+ h3 age = 34
+modify
+ otnRight1 [h3]
+join1
+ rightMemory [h4, h5, h3] // notice that h3 moves to the end
+join2
+ leftMemory [[h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5], [h1, h3], [h2, h3]] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h3 age = 35
+modify
+ otnRight1 [h3]
+join1
+ rightMemory [h4, h5, h3] // notice that h3 moves to the end
+join2
+ leftMemory [[h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5], [h0, h3], [h2, h3]] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h3 age = 36
+modify
+ otnRight1 [h3]
+join2
+ leftMemory [[h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5], [h0, h3], [h1, h3]] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h3 age = 37
+modify
+ otnRight1 [h3]
+join2
+ leftMemory [[h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5], [h0, h3], [h1, h3], [h2, h3]] // notice that all child tuples as a result of the modify are moved to the end
+retract
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+
+/**
+ * insert all and the modify h4 breaking and re-creating each join, to simulate right modifies
+ */
+assert
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5]]
+With
+ h4 age = 34
+modify
+ otnRight1 [h4]
+join1
+ rightMemory [h3, h5, h4] // notice that h4 moves to the end
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h5], [h1, h5], [h2, h5], [h1, h4], [h2, h4] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h4 age = 35
+modify
+ otnRight1 [h4]
+join1
+ rightMemory [h3, h5, h4] // notice that h4 moves to the end
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h5], [h1, h5], [h2, h5], [h0, h4], [h2, h4] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h4 age = 36
+modify
+ otnRight1 [h4]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h5], [h1, h5], [h2, h5], [h0, h4], [h1, h4] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h4 age = 38
+modify
+ otnRight1 [h4]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h5], [h1, h5], [h2, h5], [h0, h4], [h1, h4], [h2, h4] ] // notice that all child tuples as a result of the modify are moved to the end
+retract
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+
+/**
+ * insert all and the modify h5 breaking and re-creating each join, to simulate right modifies
+ */
+assert
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5]]
+With
+ h5 age = 34
+modify
+ otnRight1 [h5]
+join1
+ rightMemory [h3, h4, h5] // notice that h4 is still on the end
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h1, h5], [h2, h5] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h5 age = 35
+modify
+ otnRight1 [h5]
+join1
+ rightMemory [h3, h4, h5] // notice that h4 is still on the end
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h2, h5] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h5 age = 36
+modify
+ otnRight1 [h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5] ] // notice that all child tuples as a result of the modify are moved to the end
+With
+ h5 age = 39
+modify
+ otnRight1 [h5]
+join2
+ leftMemory [[h0, h3], [h1, h3], [h2, h3],
+ [h0, h4], [h1, h4], [h2, h4],
+ [h0, h5], [h1, h5], [h2, h5] ] // notice that all child tuples as a result of the modify are moved to the end
+retract
+ otnLeft1 [h0, h1, h2]
+ otnRight1 [h3, h4, h5]
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeAssertRetractTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeAssertRetractTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeAssertRetractTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,221 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian1, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+NotNode
+ not1, lian1, otnRight1
+ age, !=, p1
+JoinNode
+ join2, not1, otnRight2
+ age, !=, p1
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 35), new org.drools.Person('luke', 35)
+ new org.drools.Person('dave', 35), new org.drools.Person('bob', 36)
+ new org.drools.Person('obi', 36), new org.drools.Person('han', 37)
+
+
+/**
+ * check single left assertion and retraction
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+join2
+ leftMemory []
+
+/**
+ * check single right assertion and retraction
+ */
+assert
+ otnRight1 [h1]
+not1
+ rightMemory [h1]
+join2
+ leftMemory []
+retract
+ otnRight1 [h1]
+not1
+ rightMemory []
+
+/**
+ * check single left then right assertion, where age == age (does not match not)
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory [[h0]]
+assert
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0]]
+retract
+ otnRight1 [h1]
+ otnRight1 []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+/**
+ * check single left then right assertion, where age != age (matches not)
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]] // h0 is here, it'll disapear soon....
+ rightMemory []
+join2
+ leftMemory [[h0]]
+assert
+ otnRight1 [h5]
+not1
+ leftMemory [] // h0 disappears as h5 blocks it, and removes it from memory
+ rightMemory [h5]
+join2
+ leftMemory []
+retract
+ otnRight1 [h5]
+not1
+ leftMemory [[h0]] // h0 is put back in, as h5 no longer blocks
+ rightMemory []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+
+/**
+ * check single right then left assertion, where age != age (matches not)
+ */
+assert
+ otnRight1 [h5]
+not1
+ leftMemory []
+ rightMemory [h5]
+join2
+ leftMemory []
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [] // although it's inserted, you can't see it in the memory as h5 blocks it
+ rightMemory [h5]
+join2
+ leftMemory []
+retract
+ otnRight1 [h5]
+not1
+ leftMemory [[h0]] // h5 no longer blocks, so put back in
+ rightMemory []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+/**
+ * check single right then left assertion, where age == age (does not match not)
+ */
+assert
+ otnRight1 [h1]
+not1
+ leftMemory []
+ rightMemory [h1]
+join2
+ leftMemory []
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0]]
+retract
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+not1
+ leftMemory []
+ rightMemory []
+join2
+ leftMemory []
+
+// here
+
+
+/**
+ * assert two left and two right, with iterative retract and assert, age != age (not matches)
+ */
+assert
+ otnLeft1 [h0, h1]
+not1
+ leftMemory [[h0], [h1]]
+ rightMemory []
+join2
+ leftMemory [[h0], [h1]]
+assert
+ otnRight1 [h5]
+not1
+ leftMemory [] //h0 and h1 are blocked, by h5, so removed
+ rightMemory [h5, h6]
+join2
+ leftMemory []
+assert
+ otnRight1 [h6]
+not1
+ leftMemory [] //h0 and h1 are still blocked
+ rightMemory [h5, h6]
+join2
+ leftMemory []
+retract
+ otnRight1 [h5] // retract h5, the facts should still be blocked now by h6
+not1
+ leftMemory [] //h0 and h1 are still blocked
+ rightMemory [h6]
+join2
+ leftMemory []
+retract
+ otnRight1 [h6] // now there are no blockers
+not1
+ leftMemory [[h0], [h1]] // both facts go back in
+ rightMemory []
+join2
+ leftMemory [[h0], [h1]] // both facts propagate
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeIndexTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeIndexTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeIndexTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,138 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian1, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+NotNode
+ not1, lian1, otnRight1
+ age, ==, p1
+JoinNode
+ join2, not1, otnRight2
+ age, ==, p1
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 35), new org.drools.Person('luke', 35)
+ new org.drools.Person('dave', 35), new org.drools.Person('bob', 36)
+ new org.drools.Person('obi', 36), new org.drools.Person('han', 37)
+
+/**
+ * check single left then right assertion, initially not matched, the toggle matched and unmatched
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory [[h0]]
+assert
+ otnRight1 [h6]
+not1
+ leftMemory [[h0]]
+ rightMemory [h6]
+join2
+ leftMemory [[h0]]
+With
+ h6 age = 35
+modify
+ otnRight1 [h6]
+not1
+ leftMemory [] // h0 is removed from here, as it's blocked
+ rightMemory [h6]
+join2
+ leftMemory []
+With
+ h6 age = 36
+modify
+ otnRight1 [h6]
+not1
+ leftMemory [[h0]] // h0 is back again, as it's no longer blocked
+ rightMemory [h6]
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+ otnRight1 [h6]
+
+
+
+/**
+ * check two left, two right, initially not matched, toggle various matches.
+ */
+assert
+ otnRight1 [h6]
+ otnLeft1 [h0, h1]
+not1
+ leftMemory [[h0], [h1]]
+ rightMemory [h6]
+join2
+ leftMemory [[h0], [h1]]
+assert
+ otnRight1 [h7]
+With
+ h6 age = 35
+ h7 age = 35
+modify
+ otnRight1 [h6] // h6 now blocks h0 and h1
+not1
+ leftMemory []
+join2
+ leftMemory []
+modify
+ otnRight1 [h7] // now h6 and h7 block, although due to lazy only h6 blocks at the moment
+not1
+ leftMemory []
+join2
+ leftMemory []
+With
+ h1 age = 34
+modify
+ otnLeft1 [h1]
+not1
+ leftMemory [[h1]]
+join2
+ leftMemory [[h1]]
+With
+ h6 age = 34
+ h7 age = 36
+modify
+ otnRight1 [h6, h7] // h6 now blocks h1, h0 is no longer blocked
+not1
+ leftMemory [[h0]]
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h1]
+With
+ h0 age = 34
+modify
+ otnLeft1 [h0] // h0 should now be blocked by h6
+not1
+ leftMemory []
+join2
+ leftMemory []
+With
+ h0 age = 35
+ h1 age = 35
+retract
+ otnLeft1 [h0, h1]
+ otnRight1 [h6, h7]
+
+/**
+ * Test Blocking two, in index, with modify but no index change
+ */
+assert
+ otnRight1 [h3]
+ otnLeft1 [h0, h1]
+not1
+ leftMemory []
+ rightMemory [h3]
+join2
+ leftMemory []
+modify
+ otnRight1 [h3]
\ No newline at end of file
Added: labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeModifyTest.data
===================================================================
--- labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeModifyTest.data (rev 0)
+++ labs/jbossrules/branches/true_modify_20100104/drools-core/src/test/resources/org/drools/reteoo/test/NotNodeModifyTest.data 2010-01-04 22:02:34 UTC (rev 30915)
@@ -0,0 +1,119 @@
+ObjectTypeNode
+ otnLeft1, org.drools.Person
+LeftInputAdapterNode
+ lian1, otnLeft1
+ObjectTypeNode
+ otnRight1, org.drools.Person
+ObjectTypeNode
+ otnRight2, org.drools.Person
+Binding
+ p1, 0, org.drools.Person, age
+NotNode
+ not1, lian1, otnRight1
+ age, !=, p1
+JoinNode
+ join2, not1, otnRight2
+ age, !=, p1
+Facts
+ new org.drools.Person('darth', 35), new org.drools.Person('bobba', 35)
+ new org.drools.Person('yoda', 35), new org.drools.Person('luke', 35)
+ new org.drools.Person('dave', 35), new org.drools.Person('bob', 36)
+ new org.drools.Person('obi', 36), new org.drools.Person('han', 37)
+
+
+
+
+/**
+ * check single left then right assertion, initially not matched, the toggle matched and unmatched
+ */
+assert
+ otnLeft1 [h0]
+not1
+ leftMemory [[h0]]
+ rightMemory []
+join2
+ leftMemory [[h0]]
+assert
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]]
+ rightMemory [h1]
+join2
+ leftMemory [[h0]]
+With
+ h1 age = 36
+modify
+ otnRight1 [h1]
+not1
+ leftMemory [] // h0 is removed from here, as it's blocked
+ rightMemory [h1]
+join2
+ leftMemory []
+With
+ h1 age = 35
+modify
+ otnRight1 [h1]
+not1
+ leftMemory [[h0]] // h0 is back again, as it's no longer blocked
+ rightMemory [h1]
+join2
+ leftMemory [[h0]]
+retract
+ otnLeft1 [h0]
+ otnRight1 [h1]
+
+
+/**
+ * check two left, two right
+ */
+assert
+ otnRight1 [h6]
+assert
+ otnLeft1 [h0, h1]
+not1
+ leftMemory [] // memory is empty as h0 and h1 are blocked
+join2
+ leftMemory []
+assert
+ otnRight1 [h7]
+With
+ h6 age = 35
+modify
+ otnRight1 [h6] // h7 still blocks h0 and h1
+not1
+ leftMemory []
+join2
+ leftMemory []
+With
+ h7 age = 35
+modify
+ otnRight1 [h7] // h0 and h1 should now be unblocked
+not1
+ leftMemory [[h0], [h1]] // h0 and h1 appear back in memory
+join2
+ leftMemory [[h0], [h1]]
+With
+ h6 age = 36
+modify
+ otnRight1 [h6]
+not1
+ leftMemory [] // h6 blocks both
+join2
+ leftMemory []
+With
+ h0 age = 36
+modify
+ otnLeft1 [h0] // h0 is now blocked by h7, while h1 remains blocked by h6
+not1
+ leftMemory [] // remains empty
+join2
+ leftMemory []
+With
+ h0 age = 36
+ h7 age = 36
+modify
+ otnLeft1 [h0] // h0 is no longer blocked
+not1
+ leftMemory [[h0]]
+join2
+ leftMemory [[h0]]
\ No newline at end of file
More information about the jboss-svn-commits
mailing list