[jboss-svn-commits] JBL Code SVN: r6353 - 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 Sep 22 07:59:41 EDT 2006
Author: mark.proctor at jboss.com
Date: 2006-09-22 07:59:39 -0400 (Fri, 22 Sep 2006)
New Revision: 6353
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
Log:
JBRULES-498 Optimised HashMap impl
-updated AlphaNode to use FactHashSet
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2006-09-22 11:58:46 UTC (rev 6352)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AlphaNode.java 2006-09-22 11:59:39 UTC (rev 6353)
@@ -16,10 +16,6 @@
* limitations under the License.
*/
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
import org.drools.FactException;
import org.drools.RuleBaseConfiguration;
import org.drools.common.BaseNode;
@@ -29,6 +25,9 @@
import org.drools.common.PropagationContextImpl;
import org.drools.spi.FieldConstraint;
import org.drools.spi.PropagationContext;
+import org.drools.util.AbstractHashTable;
+import org.drools.util.FactHashSet;
+import org.drools.util.FactHashSet.FactEntry;
/**
* <code>AlphaNodes</code> are nodes in the <code>Rete</code> network used
@@ -115,11 +114,11 @@
public void assertObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) throws FactException {
- final Set memory = (Set) workingMemory.getNodeMemory( this );
+ final FactHashSet memory = (FactHashSet) workingMemory.getNodeMemory( this );
if ( this.constraint.isAllowed( handle.getObject(),
null,
workingMemory ) ) {
- memory.add( handle );
+ memory.add( handle, false );
sink.propagateAssertObject( handle,
context,
workingMemory );
@@ -129,9 +128,8 @@
public void retractObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- final Set memory = (Set) workingMemory.getNodeMemory( this );
+ final FactHashSet memory = (FactHashSet) workingMemory.getNodeMemory( this );
if ( memory.remove( handle ) ) {
-
this.sink.propagateRetractObject( handle,
context,
workingMemory,
@@ -142,12 +140,12 @@
public void modifyObject(final InternalFactHandle handle,
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
- final Set memory = (Set) workingMemory.getNodeMemory( this );
+ final FactHashSet memory = (FactHashSet) workingMemory.getNodeMemory( this );
if ( this.constraint.isAllowed( handle.getObject(),
null,
workingMemory ) ) {
- if ( memory.add( handle ) ) {
+ if ( memory.add( handle, true ) ) {
this.sink.propagateAssertObject( handle,
context,
workingMemory );
@@ -171,15 +169,18 @@
final PropagationContext context) {
this.attachingNewNode = true;
- final Set memory = (Set) workingMemory.getNodeMemory( this );
+ final FactHashSet memory = (FactHashSet) workingMemory.getNodeMemory( this );
+ FactEntry[] entries = memory.getTable();
+ for ( int i = 0, length = entries.length; i < length; i++ ) {
+ FactEntry current = entries[i];
+ while ( current != null ) {
+ this.sink.propagateNewObjectSink( current.getFactHandle(),
+ context,
+ workingMemory );
+ current = ( FactEntry ) current.getNext();
+ }
+ }
- for ( final Iterator it = memory.iterator(); it.hasNext(); ) {
- final InternalFactHandle handle = (InternalFactHandle) it.next();
- this.sink.propagateNewObjectSink( handle,
- context,
- workingMemory );
- }
-
this.attachingNewNode = false;
}
@@ -203,7 +204,7 @@
* Creates a HashSet for the AlphaNode's memory.
*/
public Object createMemory(final RuleBaseConfiguration config) {
- return new HashSet();
+ return new FactHashSet();
}
public String toString() {
More information about the jboss-svn-commits
mailing list