[jboss-svn-commits] JBL Code SVN: r19414 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Apr 4 09:08:49 EDT 2008


Author: tirelli
Date: 2008-04-04 09:08:49 -0400 (Fri, 04 Apr 2008)
New Revision: 19414

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java
Log:
JBRULES-1520: fixing FromNode.updateSink()

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java	2008-04-04 12:00:10 UTC (rev 19413)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FromNode.java	2008-04-04 13:08:49 UTC (rev 19414)
@@ -90,12 +90,28 @@
         if ( this.tupleMemoryEnabled ) {
             memory.betaMemory.getLeftTupleMemory().add( leftTuple );
         }
-        
+
         if ( this.sink.size() == 0 ) {
             // nothing to do
             return;
         }
-        
+
+        evaluateAndPropagate( leftTuple,
+                              context,
+                              workingMemory,
+                              memory );
+    }
+
+    /**
+     * @param leftTuple
+     * @param context
+     * @param workingMemory
+     * @param memory
+     */
+    private void evaluateAndPropagate(final LeftTuple leftTuple,
+                                      final PropagationContext context,
+                                      final InternalWorkingMemory workingMemory,
+                                      final FromMemory memory) {
         this.betaConstraints.updateFromTuple( memory.betaMemory.getContext(),
                                               workingMemory,
                                               leftTuple );
@@ -109,9 +125,10 @@
             final InternalFactHandle handle = workingMemory.getFactHandleFactory().newFactHandle( object,
                                                                                                   false,
                                                                                                   workingMemory );
-            
-            RightTuple rightTuple = new RightTuple( handle, null );
 
+            RightTuple rightTuple = new RightTuple( handle,
+                                                    null );
+
             boolean isAllowed = true;
             if ( this.alphaConstraints != null ) {
                 // First alpha node filters
@@ -134,7 +151,7 @@
                                                     rightTuple,
                                                     context,
                                                     workingMemory,
-                                                    this.tupleMemoryEnabled);
+                                                    this.tupleMemoryEnabled );
             } else {
                 workingMemory.getFactHandleFactory().destroyFactHandle( handle );
             }
@@ -149,8 +166,10 @@
 
         final FromMemory memory = (FromMemory) workingMemory.getNodeMemory( this );
         memory.betaMemory.getLeftTupleMemory().remove( leftTuple );
-        
-        this.sink.propagateRetractLeftTupleDestroyRightTuple( leftTuple, context, workingMemory );
+
+        this.sink.propagateRetractLeftTupleDestroyRightTuple( leftTuple,
+                                                              context,
+                                                              workingMemory );
     }
 
     public void attach() {
@@ -207,27 +226,10 @@
 
         final Iterator tupleIter = memory.betaMemory.getLeftTupleMemory().iterator();
         for ( LeftTuple leftTuple = (LeftTuple) tupleIter.next(); leftTuple != null; leftTuple = (LeftTuple) tupleIter.next() ) {
-            if( this.sink.size() == 1 ) { 
-                // means we had no sink before, so no calculated matches
-                assertLeftTuple( leftTuple, context, workingMemory );
-            } else {
-                // we previously calculated matches, so, just re-use them
-                LeftTuple child = leftTuple.getBetaChildren();
-                RightTuple match = null;
-                while( child != null ) {
-                    if( match != child.getRightParent() ) {
-                        match = child.getRightParent();
-                        sink.assertLeftTuple( new LeftTuple( leftTuple,
-                                                             match,
-                                                             sink,
-                                                             this.tupleMemoryEnabled ),
-                                              context,
-                                              workingMemory );
-                        
-                    }
-                    child = child.getLeftParentNext();
-                }
-            }
+            evaluateAndPropagate( leftTuple,
+                                  context,
+                                  workingMemory,
+                                  memory );
         }
     }
 




More information about the jboss-svn-commits mailing list