[jboss-svn-commits] JBL Code SVN: r19670 - labs/jbossrules/branches/temporal_rete/drools-core-window-PB/src/main/java/org/drools/reteoo.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Apr 21 09:03:26 EDT 2008


Author: mgroch
Date: 2008-04-21 09:03:25 -0400 (Mon, 21 Apr 2008)
New Revision: 19670

Modified:
   labs/jbossrules/branches/temporal_rete/drools-core-window-PB/src/main/java/org/drools/reteoo/TimeWindowNode.java
Log:
modifications from NTA to piggy-backing approach

Modified: labs/jbossrules/branches/temporal_rete/drools-core-window-PB/src/main/java/org/drools/reteoo/TimeWindowNode.java
===================================================================
--- labs/jbossrules/branches/temporal_rete/drools-core-window-PB/src/main/java/org/drools/reteoo/TimeWindowNode.java	2008-04-21 13:00:55 UTC (rev 19669)
+++ labs/jbossrules/branches/temporal_rete/drools-core-window-PB/src/main/java/org/drools/reteoo/TimeWindowNode.java	2008-04-21 13:03:25 UTC (rev 19670)
@@ -36,6 +36,7 @@
 import org.drools.spi.AlphaNodeFieldConstraint;
 import org.drools.spi.PropagationContext;
 import org.drools.temporal.GlobalSessionClockImpl;
+import org.drools.temporal.SessionClock;
 import org.drools.temporal.TimeWindowNodeExpirationManager;
 import org.drools.util.ArrayUtils;
 import org.drools.util.Entry;
@@ -91,12 +92,13 @@
         this.lock = new ReentrantLock();
     }
 	
-/*	public void assertTuple(final ReteTuple leftTuple,
+    // original method signature => is called by original Rete engine when new event tuple is inserted (!= modified) into wm
+	public void assertTuple(final ReteTuple leftTuple,
              final PropagationContext context,
              final InternalWorkingMemory workingMemory) {
 		// original method signature 
 		this.assertTuple(leftTuple, context, workingMemory, false);
-	}*/
+	}
 
     /**
      * @inheritDoc
@@ -119,7 +121,8 @@
      */
     public void assertTuple(final ReteTuple leftTuple,
                             final PropagationContext context,
-                            final InternalWorkingMemory workingMemory/*,
+                            final InternalWorkingMemory workingMemory,
+                            final boolean isPartOfUpdate/*,
                             final boolean isInvokedByExpirationChecker*/) {
        
         try {
@@ -128,9 +131,11 @@
         	lock.lock(); myLogger.debug ("\nTimeWindowNode, Thread "+Thread.currentThread().getId()+": ENTERING assertTuple("+leftTuple.getLastHandle().getObject().toString()+"); currentHoldCount: "+lock.getHoldCount());
         	
         	// update window bounds according to current session clock value
-        	this.updateWindowBounds(GlobalSessionClockImpl.getInstance().getCurrentTime());
+        	long currentTime = GlobalSessionClockImpl.getInstance().getCurrentTime();
 	        // remove facts and tuples being outside window bounds from items to be considered for aggregation
-	        //updateNodeMemory(memory, context, workingMemory);
+	        if (!isPartOfUpdate && this.updateWindowBounds(currentTime) 
+	        		&& this.expirationManager.getNextExpiration() != null && currentTime <= this.expirationManager.getNextExpiration())
+	        	this.expirationManager.determineExpiredEvents(currentTime, workingMemory);
         
 	        final TimeWindowMemory memory = (TimeWindowMemory) workingMemory.getNodeMemory( this );
 	        
@@ -332,8 +337,13 @@
     		lock.lock(); myLogger.debug ("\nTimeWindowNode, Thread "+Thread.currentThread().getId()+": ENTERING assertObject("+handle.getObject().toString()+"); currentHoldCount: "+lock.getHoldCount());
 
     		// update window bounds according to current session clock value
-    		this.updateWindowBounds(GlobalSessionClockImpl.getInstance().getCurrentTime());
-    		
+    		long currentTime = GlobalSessionClockImpl.getInstance().getCurrentTime();
+	        // remove facts and tuples being outside window bounds from items to be considered for aggregation
+	        if (this.updateWindowBounds(currentTime) && this.expirationManager.getNextExpiration() != null 
+	        		&& currentTime <= this.expirationManager.getNextExpiration())
+	        	
+	        	this.expirationManager.determineExpiredEvents(currentTime, workingMemory);
+	        
 	        final TimeWindowMemory memory = (TimeWindowMemory) workingMemory.getNodeMemory( this );
 	        
 	        boolean meetsWindowConstraints = true;
@@ -388,7 +398,8 @@
 		                                       false*/);
 		                    this.assertTuple( tuple,
 		                                      context,
-		                                      workingMemory/*,
+		                                      workingMemory,
+		                                      true/*,
 		                                      false*/);
 		                }
 		            }
@@ -448,7 +459,8 @@
 	                                       false*/);
 	                    this.assertTuple( tuple,
 	                                      context,
-	                                      workingMemory/*, 
+	                                      workingMemory,
+	                                      true/*, 
 	                                      false*/);
 	                }
 	            }
@@ -940,7 +952,8 @@
 	                                    true*/);
 	                 this.assertTuple( tupleToModify,
 	                		 		   DEFAULT_RETRACTION_CONTEXT, 
-	                                   workingMemory/*,
+	                                   workingMemory,
+	                                   true/*,
 	                                   true*/);
 	         }
 	    	




More information about the jboss-svn-commits mailing list