[jboss-svn-commits] JBL Code SVN: r19205 - in labs/jbossrules/trunk/drools-core/src: test/java/org/drools/reteoo and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Mar 22 17:25:48 EDT 2008


Author: tirelli
Date: 2008-03-22 17:25:48 -0400 (Sat, 22 Mar 2008)
New Revision: 19205

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
Log:
commiting some collect changes

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java	2008-03-22 16:50:06 UTC (rev 19204)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java	2008-03-22 21:25:48 UTC (rev 19205)
@@ -16,11 +16,12 @@
 
 package org.drools.reteoo;
 
-import java.util.Arrays;
-import java.util.Collection;
 import java.io.IOException;
-import java.io.ObjectOutput;
 import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collection;
 
 import org.drools.RuleBaseConfiguration;
 import org.drools.common.BetaConstraints;
@@ -33,9 +34,6 @@
 import org.drools.spi.PropagationContext;
 import org.drools.util.ArrayUtils;
 import org.drools.util.Entry;
-import org.drools.util.FactEntry;
-import org.drools.util.Iterator;
-import org.drools.util.ObjectHashMap.ObjectEntry;
 
 /**
  * @author etirelli
@@ -134,31 +132,33 @@
         final InternalFactHandle resultHandle = workingMemory.getFactHandleFactory().newFactHandle( result,
                                                                                                     false,
                                                                                                     workingMemory );
-        CollectResult colresult = new CollectResult();
-        colresult.handle = resultHandle;
-        colresult.propagated = false;
+        final RightTuple resultTuple = new RightTuple( resultHandle,
+                                                       this );
 
         // do not add tuple and result to the memory in sequential mode
         if ( this.tupleMemoryEnabled ) {
             memory.betaMemory.getLeftTupleMemory().add( leftTuple );
             memory.betaMemory.getCreatedHandles().put( leftTuple,
-                                                       colresult,
+                                                       resultTuple,
                                                        false );
         }
 
-        final Iterator it = memory.betaMemory.getRightTupleMemory().iterator( leftTuple );
         this.constraints.updateFromTuple( memory.betaMemory.getContext(),
                                           workingMemory,
                                           leftTuple );
 
-        for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
-            InternalFactHandle handle = entry.getFactHandle();
+        for ( RightTuple rightTuple = memory.betaMemory.getRightTupleMemory().getFirst( leftTuple ); rightTuple != null; rightTuple = (RightTuple) rightTuple.getNext() ) {
+            InternalFactHandle handle = rightTuple.getFactHandle();
             if ( this.constraints.isAllowedCachedLeft( memory.betaMemory.getContext(),
                                                        handle ) ) {
                 if ( this.unwrapRightObject ) {
                     handle = ((LeftTuple) handle.getObject()).getLastHandle();
                 }
                 result.add( handle.getObject() );
+                
+                // linking left tuple to the right tuple children list
+                leftTuple.setRightParentNext( rightTuple.getBetaChildren() );
+                rightTuple.setBetaChildren( leftTuple );
             }
         }
 
@@ -180,9 +180,8 @@
                                                 leftTuple );
             if ( this.resultsBinder.isAllowedCachedLeft( memory.resultsContext,
                                                          resultHandle ) ) {
-                colresult.propagated = true;
                 this.sink.propagateAssertLeftTuple( leftTuple,
-                                                    resultHandle,
+                                                    resultTuple,
                                                     context,
                                                     workingMemory );
             }
@@ -198,23 +197,16 @@
                                  final InternalWorkingMemory workingMemory) {
 
         final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
-        if ( memory.betaMemory.getLeftTupleMemory().remove( leftTuple ) == null ) {
-            return;
-        }
-        CollectResult result = (CollectResult) memory.betaMemory.getCreatedHandles().remove( leftTuple );
-        final InternalFactHandle handle = result.handle;
+        memory.betaMemory.getLeftTupleMemory().remove( leftTuple );
 
-        // if tuple was propagated
-        if ( result.propagated ) {
+        final RightTuple resultTuple = (RightTuple) memory.betaMemory.getCreatedHandles().remove( leftTuple );
 
+        if ( leftTuple.getBetaChildren() != null ) {
             this.sink.propagateRetractLeftTuple( leftTuple,
-                                                 handle,
                                                  context,
                                                  workingMemory );
-
-            // Destroying the acumulate result object
-            workingMemory.getFactHandleFactory().destroyFactHandle( handle );
         }
+        workingMemory.getFactHandleFactory().destroyFactHandle( resultTuple.getFactHandle() );
     }
 
     /**
@@ -231,8 +223,11 @@
                              final InternalWorkingMemory workingMemory) {
 
         final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
-        memory.betaMemory.getRightTupleMemory().add( factHandle );
+        final RightTuple rightTuple = new RightTuple( factHandle,
+                                                      this );
 
+        memory.betaMemory.getRightTupleMemory().add( rightTuple );
+
         if ( !this.tupleMemoryEnabled ) {
             // do nothing here, as we know there are no left tuples at this stage in sequential mode.
             return;
@@ -250,7 +245,7 @@
                                                         tuple ) ) {
                 this.modifyTuple( true,
                                   tuple,
-                                  factHandle,
+                                  rightTuple,
                                   context,
                                   workingMemory );
             }
@@ -265,35 +260,23 @@
      *  If an object is retract, call modify tuple for each
      *  tuple match.
      */
-    public void retractObject(final InternalFactHandle handle,
-                              final PropagationContext context,
-                              final InternalWorkingMemory workingMemory) {
-
+    public void retractRightTuple(final RightTuple rightTuple,
+                                  final PropagationContext context,
+                                  final InternalWorkingMemory workingMemory) {
         final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
-        if ( !memory.betaMemory.getRightTupleMemory().remove( handle ) ) {
-            return;
-        }
+        memory.betaMemory.getRightTupleMemory().remove( rightTuple );
 
         this.constraints.updateFromFactHandle( memory.betaMemory.getContext(),
                                                workingMemory,
-                                               handle );
+                                               rightTuple.getFactHandle() );
 
-        // need to clone the tuples to avoid concurrent modification exceptions
-        Entry[] tuples = memory.betaMemory.getLeftTupleMemory().toArray();
-        for ( int i = 0; i < tuples.length; i++ ) {
-            LeftTuple tuple = (LeftTuple) tuples[i];
-            if ( this.constraints.isAllowedCachedRight( memory.betaMemory.getContext(),
-                                                        tuple ) ) {
-
-                this.modifyTuple( false,
-                                  tuple,
-                                  handle,
-                                  context,
-                                  workingMemory );
-            }
+        for( LeftTuple leftTuple = rightTuple.getBetaChildren(); leftTuple != null; leftTuple = rightTuple.getBetaChildren() ) {
+            this.modifyTuple( false,
+                              leftTuple,
+                              rightTuple,
+                              context,
+                              workingMemory );
         }
-
-        this.constraints.resetFactHandle( memory.betaMemory.getContext() );
     }
 
     /**
@@ -307,44 +290,44 @@
      */
     public void modifyTuple(final boolean isAssert,
                             final LeftTuple leftTuple,
-                            InternalFactHandle handle,
+                            final RightTuple rightTuple,
                             final PropagationContext context,
                             final InternalWorkingMemory workingMemory) {
 
         final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
 
-        CollectResult result = (CollectResult) memory.betaMemory.getCreatedHandles().get( leftTuple );
+        RightTuple result = (RightTuple) memory.betaMemory.getCreatedHandles().get( leftTuple );
 
         // if tuple was propagated
-        if ( result.propagated ) {
+        if ( leftTuple.getBetaChildren() != null ) {
             this.sink.propagateRetractLeftTuple( leftTuple,
-                                                 result.handle,
                                                  context,
                                                  workingMemory );
-            result.propagated = false;
         }
 
         // if there is a subnetwork, we need to unwrapp the object from inside the tuple
+        InternalFactHandle handle = rightTuple.getFactHandle(); 
         if ( this.unwrapRightObject ) {
             handle = ((LeftTuple) handle.getObject()).getLastHandle();
         }
 
         if ( context.getType() == PropagationContext.ASSERTION ) {
-            ((Collection) result.handle.getObject()).add( handle.getObject() );
+            ((Collection) result.getFactHandle().getObject()).add( handle.getObject() );
         } else if ( context.getType() == PropagationContext.RETRACTION ) {
-            ((Collection) result.handle.getObject()).remove( handle.getObject() );
+            ((Collection) result.getFactHandle().getObject()).remove( handle.getObject() );
+            rightTuple.setBetaChildren( leftTuple.getRightParentNext() );
         } else if ( context.getType() == PropagationContext.MODIFICATION || context.getType() == PropagationContext.RULE_ADDITION || context.getType() == PropagationContext.RULE_REMOVAL ) {
             if ( isAssert ) {
-                ((Collection) result.handle.getObject()).add( handle.getObject() );
+                ((Collection) result.getFactHandle().getObject()).add( handle.getObject() );
             } else {
-                ((Collection) result.handle.getObject()).remove( handle.getObject() );
+                ((Collection) result.getFactHandle().getObject()).remove( handle.getObject() );
             }
         }
 
         // First alpha node filters
         boolean isAllowed = true;
         for ( int i = 0, length = this.resultConstraints.length; i < length; i++ ) {
-            if ( !this.resultConstraints[i].isAllowed( result.handle,
+            if ( !this.resultConstraints[i].isAllowed( result.getFactHandle(),
                                                        workingMemory,
                                                        memory.alphaContexts[i] ) ) {
                 isAllowed = false;
@@ -356,10 +339,9 @@
                                                 workingMemory,
                                                 leftTuple );
             if ( this.resultsBinder.isAllowedCachedLeft( memory.resultsContext,
-                                                         result.handle ) ) {
-                result.propagated = true;
+                                                         result.getFactHandle() ) ) {
                 this.sink.propagateAssertLeftTuple( leftTuple,
-                                                    result.handle,
+                                                    result,
                                                     context,
                                                     workingMemory );
             }
@@ -371,17 +353,17 @@
     public void updateSink(final LeftTupleSink sink,
                            final PropagationContext context,
                            final InternalWorkingMemory workingMemory) {
-        final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
-
-        final Iterator it = memory.betaMemory.getCreatedHandles().iterator();
-
-        for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
-            CollectResult result = (CollectResult) entry.getValue();
-            sink.assertLeftTuple( new LeftTuple( (LeftTuple) entry.getKey(),
-                                                 result.handle ),
-                                  context,
-                                  workingMemory );
-        }
+//        final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( this );
+//
+//        final Iterator it = memory.betaMemory.getCreatedHandles().iterator();
+//
+//        for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
+//            CollectResult result = (CollectResult) entry.getValue();
+//            sink.assertLeftTuple( new LeftTuple( (LeftTuple) entry.getKey(),
+//                                                 result.handle ),
+//                                  context,
+//                                  workingMemory );
+//        }
     }
 
     /* (non-Javadoc)
@@ -431,16 +413,12 @@
         return memory;
     }
 
-    public static class CollectMemory {
+    public static class CollectMemory
+        implements
+        Serializable {
         private static final long serialVersionUID = 400L;
         public BetaMemory         betaMemory;
         public ContextEntry[]     resultsContext;
         public ContextEntry[]     alphaContexts;
     }
-
-    private static class CollectResult {
-        // keeping attributes public just for performance
-        public InternalFactHandle handle;
-        public boolean            propagated;
-    }
 }

Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java	2008-03-22 16:50:06 UTC (rev 19204)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java	2008-03-22 21:25:48 UTC (rev 19205)
@@ -67,14 +67,14 @@
                                                          null,
                                                          null );
         this.contextRetract = new PropagationContextImpl( 0,
-                                                         PropagationContext.RETRACTION,
-                                                         null,
-                                                         null );
+                                                          PropagationContext.RETRACTION,
+                                                          null,
+                                                          null );
 
         ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
         BuildContext buildContext = new BuildContext( ruleBase,
                                                       ruleBase.getReteooBuilder().getIdGenerator() );
-        
+
         this.workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
 
         this.tupleSource = new MockTupleSource( 4 );
@@ -83,10 +83,10 @@
 
         final ObjectType srcObjType = new ClassObjectType( String.class );
         final Pattern sourcePattern = new Pattern( 0,
-                                                srcObjType );
+                                                   srcObjType );
         final ObjectType resultObjType = new ClassObjectType( LinkedList.class );
         final Pattern resultPattern = new Pattern( 1,
-                                                resultObjType );
+                                                   resultObjType );
         this.collect = new Collect( sourcePattern,
                                     resultPattern );
 
@@ -126,12 +126,18 @@
                              0,
                              this.sink.getAsserted().size() );
 
-        this.node.assertLeftTuple( new LeftTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "cheese", false, null ) ),
-                               this.contextAssert,
-                               this.workingMemory );
-        this.node.assertLeftTuple( new LeftTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese", false, null ) ),
-                               this.contextAssert,
-                               this.workingMemory );
+        this.node.assertLeftTuple( new LeftTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
+                                                                                                           false,
+                                                                                                           null ),
+                                                  this.node ),
+                                   this.contextAssert,
+                                   this.workingMemory );
+        this.node.assertLeftTuple( new LeftTuple( this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
+                                                                                                           false,
+                                                                                                           null ),
+                                                  this.node ),
+                                   this.contextAssert,
+                                   this.workingMemory );
 
         Assert.assertEquals( "Two tuples should have been propagated",
                              2,
@@ -150,13 +156,16 @@
     }
 
     public void testAssertTuple() {
-        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese", false, null );
-        final LeftTuple tuple0 = new LeftTuple( f0 );
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
+                                                                                                                  false,
+                                                                                                                  null );
+        final LeftTuple tuple0 = new LeftTuple( f0,
+                                                this.node );
 
         // assert tuple, should add one to left memory
         this.node.assertLeftTuple( tuple0,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
         // check memories 
         assertEquals( 1,
                       this.memory.betaMemory.getLeftTupleMemory().size() );
@@ -166,12 +175,15 @@
                            ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
 
         // assert tuple, should add left memory 
-        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese", false, null );
+        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
+                                                                                                                  false,
+                                                                                                                  null );
 
-        final LeftTuple tuple1 = new LeftTuple( f1 );
+        final LeftTuple tuple1 = new LeftTuple( f1,
+                                                this.node );
         this.node.assertLeftTuple( tuple1,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
         assertEquals( 2,
                       this.memory.betaMemory.getLeftTupleMemory().size() );
         Assert.assertTrue( "An empty collection should be propagated",
@@ -186,10 +198,15 @@
     }
 
     public void testAssertTupleWithObjects() {
-        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese", false, null );
-        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese", false, null );
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
+                                                                                                                  false,
+                                                                                                                  null );
+        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
+                                                                                                                  false,
+                                                                                                                  null );
 
-        final LeftTuple tuple0 = new LeftTuple( f0 );
+        final LeftTuple tuple0 = new LeftTuple( f0,
+                                                this.node );
 
         this.node.assertObject( f0,
                                 this.contextAssert,
@@ -200,8 +217,8 @@
 
         // assert tuple, should add one to left memory
         this.node.assertLeftTuple( tuple0,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
         // check memories 
         assertEquals( 1,
                       this.memory.betaMemory.getLeftTupleMemory().size() );
@@ -212,10 +229,11 @@
                              ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
 
         // assert tuple, should add left memory 
-        final LeftTuple tuple1 = new LeftTuple( f1 );
+        final LeftTuple tuple1 = new LeftTuple( f1,
+                                                this.node );
         this.node.assertLeftTuple( tuple1,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
         assertEquals( 2,
                       this.memory.betaMemory.getLeftTupleMemory().size() );
         Assert.assertEquals( "Wrong number of elements in matching objects list ",
@@ -231,14 +249,17 @@
     }
 
     public void testRetractTuple() {
-        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese", false, null );
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
+                                                                                                                  false,
+                                                                                                                  null );
 
-        final LeftTuple tuple0 = new LeftTuple( f0 );
+        final LeftTuple tuple0 = new LeftTuple( f0,
+                                                this.node );
 
         // assert tuple, should add one to left memory
         this.node.assertLeftTuple( tuple0,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
         // check memories 
         assertEquals( 1,
                       this.memory.betaMemory.getLeftTupleMemory().size() );
@@ -248,8 +269,8 @@
                            ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
 
         this.node.retractLeftTuple( tuple0,
-                                this.contextRetract,
-                                this.workingMemory );
+                                    this.contextRetract,
+                                    this.workingMemory );
         assertEquals( 0,
                       this.memory.betaMemory.getLeftTupleMemory().size() );
         assertEquals( 1,
@@ -259,15 +280,20 @@
     }
 
     public void testAssertObject() {
-        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese", false, null );
-        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese", false, null );
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
+                                                                                                                  false,
+                                                                                                                  null );
+        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
+                                                                                                                  false,
+                                                                                                                  null );
 
-        final LeftTuple tuple0 = new LeftTuple( f0 );
+        final LeftTuple tuple0 = new LeftTuple( f0,
+                                                this.node );
 
         // assert tuple, should add one to left memory
         this.node.assertLeftTuple( tuple0,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
 
         // check memory 
         assertEquals( 1,
@@ -303,10 +329,15 @@
     }
 
     public void testRetractObject() {
-        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese", false, null );
-        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese", false, null );
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
+                                                                                                                  false,
+                                                                                                                  null );
+        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
+                                                                                                                  false,
+                                                                                                                  null );
 
-        final LeftTuple tuple0 = new LeftTuple( f0 );
+        final LeftTuple tuple0 = new LeftTuple( f0,
+                                                this.node );
 
         this.node.assertObject( f0,
                                 this.contextAssert,
@@ -319,8 +350,8 @@
 
         // assert tuple, should add one to left memory
         this.node.assertLeftTuple( tuple0,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
 
         // check memory 
         assertEquals( 1,
@@ -333,9 +364,9 @@
                              2,
                              ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
 
-        this.node.retractObject( f1,
-                                 this.contextRetract,
-                                 this.workingMemory );
+        this.node.retractRightTuple( f1.getRightTuple(),
+                                     this.contextRetract,
+                                     this.workingMemory );
         assertEquals( 1,
                       this.memory.betaMemory.getRightTupleMemory().size() );
         assertEquals( 1,
@@ -346,9 +377,9 @@
                              1,
                              ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 1 ))[0]).get( 1 )).getObject()).size() );
 
-        this.node.retractObject( f0,
-                                 this.contextRetract,
-                                 this.workingMemory );
+        this.node.retractRightTuple( f0.getRightTuple(),
+                                     this.contextRetract,
+                                     this.workingMemory );
         assertEquals( 0,
                       this.memory.betaMemory.getRightTupleMemory().size() );
         assertEquals( 2,
@@ -365,9 +396,9 @@
         ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
         BuildContext buildContext = new BuildContext( ruleBase,
                                                       ruleBase.getReteooBuilder().getIdGenerator() );
-        
-        final ReteooWorkingMemory workingMemory = ( ReteooWorkingMemory ) ruleBase.newStatefulSession();
 
+        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
+
         final MockObjectSource objectSource = new MockObjectSource( 1 );
         final MockTupleSource tupleSource = new MockTupleSource( 1 );
 
@@ -379,7 +410,7 @@
                                                          EmptyBetaConstraints.getInstance(),
                                                          this.collect,
                                                          false,
-                                                         buildContext  );
+                                                         buildContext );
 
         final CollectMemory memory = (CollectMemory) workingMemory.getNodeMemory( collectNode );
 
@@ -392,14 +423,19 @@
 
         this.workingMemory = new ReteooWorkingMemory( 1,
                                                       (ReteooRuleBase) RuleBaseFactory.newRuleBase( conf ) );
-        
+
         this.memory = (CollectMemory) this.workingMemory.getNodeMemory( this.node );
         this.node.setLeftTupleMemoryEnabled( false );
 
-        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese", false, null );
-        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese", false, null );
+        final DefaultFactHandle f0 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "cheese",
+                                                                                                                  false,
+                                                                                                                  null );
+        final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.getFactHandleFactory().newFactHandle( "other cheese",
+                                                                                                                  false,
+                                                                                                                  null );
 
-        final LeftTuple tuple0 = new LeftTuple( f0 );
+        final LeftTuple tuple0 = new LeftTuple( f0,
+                                                this.node );
 
         this.node.assertObject( f0,
                                 this.contextAssert,
@@ -410,8 +446,8 @@
 
         // assert tuple, should not add to left memory, since we are in sequential mode
         this.node.assertLeftTuple( tuple0,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
         // check memories 
         assertNull( this.memory.betaMemory.getLeftTupleMemory() );
         assertEquals( 2,
@@ -421,10 +457,11 @@
                              ((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
 
         // assert tuple, should not add to left memory, since we are in sequential mode
-        final LeftTuple tuple1 = new LeftTuple( f1 );
+        final LeftTuple tuple1 = new LeftTuple( f1,
+                                                this.node );
         this.node.assertLeftTuple( tuple1,
-                               this.contextAssert,
-                               this.workingMemory );
+                                   this.contextAssert,
+                                   this.workingMemory );
         assertNull( this.memory.betaMemory.getLeftTupleMemory() );
         Assert.assertEquals( "Wrong number of elements in matching objects list ",
                              2,




More information about the jboss-svn-commits mailing list