[jboss-svn-commits] JBL Code SVN: r7151 - in labs/jbossrules/trunk/drools-core/src: main/java/org/drools/common main/java/org/drools/reteoo main/java/org/drools/util test/java/org/drools/reteoo test/java/org/drools/util
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Oct 26 15:50:44 EDT 2006
Author: mark.proctor at jboss.com
Date: 2006-10-26 15:50:28 -0400 (Thu, 26 Oct 2006)
New Revision: 7151
Added:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FactHandleMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java
Removed:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java
Log:
-Added Tuple indexed memory
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultBetaConstraints.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -28,11 +28,12 @@
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.spi.Constraint;
import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
+import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
-import org.drools.util.FieldIndexHashTable.FieldIndex;
+import org.drools.util.TupleIndexHashTable;
+import org.drools.util.AbstractHashTable.FieldIndex;
public class DefaultBetaConstraints
implements
@@ -190,8 +191,8 @@
}
FieldIndex[] indexes = ( FieldIndex[] ) list.toArray( new FieldIndex[ list.size() ] );
- memory = new BetaMemory( new TupleHashTable(),
- new FieldIndexHashTable( indexes ) );
+ memory = new BetaMemory( new TupleIndexHashTable( indexes ),
+ new FactHandleIndexHashTable( indexes ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DoubleBetaConstraints.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -27,11 +27,12 @@
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
+import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
-import org.drools.util.FieldIndexHashTable.FieldIndex;
+import org.drools.util.TupleIndexHashTable;
+import org.drools.util.AbstractHashTable.FieldIndex;
public class DoubleBetaConstraints
implements
@@ -159,8 +160,8 @@
if ( !list.isEmpty() ) {
final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
- memory = new BetaMemory( new TupleHashTable(),
- new FieldIndexHashTable( indexes ) );
+ memory = new BetaMemory( new TupleIndexHashTable( indexes ),
+ new FactHandleIndexHashTable( indexes ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/QuadroupleBetaConstraints.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -27,11 +27,11 @@
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
+import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
-import org.drools.util.FieldIndexHashTable.FieldIndex;
+import org.drools.util.AbstractHashTable.FieldIndex;
public class QuadroupleBetaConstraints
implements
@@ -246,7 +246,7 @@
if ( !list.isEmpty() ) {
final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
memory = new BetaMemory( new TupleHashTable(),
- new FieldIndexHashTable( indexes ) );
+ new FactHandleIndexHashTable( indexes ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/SingleBetaConstraints.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -25,11 +25,12 @@
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
+import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
-import org.drools.util.FieldIndexHashTable.FieldIndex;
+import org.drools.util.TupleIndexHashTable;
+import org.drools.util.AbstractHashTable.FieldIndex;
public class SingleBetaConstraints
implements
@@ -114,8 +115,8 @@
final VariableConstraint variableConstraint = (VariableConstraint) this.constraint;
final FieldIndex index = new FieldIndex( variableConstraint.getFieldExtractor(),
variableConstraint.getRequiredDeclarations()[0] );
- memory = new BetaMemory( new TupleHashTable(),
- new FieldIndexHashTable( new FieldIndex[]{index} ) );
+ memory = new BetaMemory( new TupleIndexHashTable( new FieldIndex[]{index} ),
+ new FactHandleIndexHashTable( new FieldIndex[]{index} ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/TripleBetaConstraints.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -27,11 +27,12 @@
import org.drools.rule.VariableConstraint;
import org.drools.spi.BetaNodeFieldConstraint;
import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
+import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.LinkedList;
import org.drools.util.LinkedListEntry;
import org.drools.util.TupleHashTable;
-import org.drools.util.FieldIndexHashTable.FieldIndex;
+import org.drools.util.TupleIndexHashTable;
+import org.drools.util.AbstractHashTable.FieldIndex;
public class TripleBetaConstraints
implements
@@ -212,8 +213,8 @@
if ( !list.isEmpty() ) {
final FieldIndex[] indexes = (FieldIndex[]) list.toArray( new FieldIndex[list.size()] );
- memory = new BetaMemory( new TupleHashTable(),
- new FieldIndexHashTable( indexes ) );
+ memory = new BetaMemory( new TupleIndexHashTable( indexes ),
+ new FactHandleIndexHashTable( indexes ) );
} else {
memory = new BetaMemory( new TupleHashTable(),
new FactHashTable() );
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/AccumulateNode.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -117,7 +117,7 @@
final List matchingObjects = new ArrayList();
- final Iterator it = memory.getObjectMemory().iterator( leftTuple );
+ final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
this.constraints.updateFromTuple( workingMemory,
leftTuple );
@@ -198,7 +198,7 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- memory.getObjectMemory().add( handle );
+ memory.getFactHandleMemory().add( handle );
final Iterator it = memory.getTupleMemory().iterator();
this.constraints.updateFromFactHandle( workingMemory,
@@ -225,7 +225,7 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- if ( !memory.getObjectMemory().remove( handle ) ) {
+ if ( !memory.getFactHandleMemory().remove( handle ) ) {
return;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/BetaMemory.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -4,21 +4,21 @@
import org.drools.util.TupleHashTable;
public class BetaMemory {
- private TupleHashTable tupleMemory;
- private ObjectHashTable objectMemory;
+ private TupleMemory tupleMemory;
+ private FactHandleMemory factHandleMemory;
private ObjectHashMap createdHandles;
- public BetaMemory(final TupleHashTable tupleMemory,
- final ObjectHashTable objectMemory) {
+ public BetaMemory(final TupleMemory tupleMemory,
+ final FactHandleMemory objectMemory) {
this.tupleMemory = tupleMemory;
- this.objectMemory = objectMemory;
+ this.factHandleMemory = objectMemory;
}
- public ObjectHashTable getObjectMemory() {
- return this.objectMemory;
+ public FactHandleMemory getFactHandleMemory() {
+ return this.factHandleMemory;
}
- public TupleHashTable getTupleMemory() {
+ public TupleMemory getTupleMemory() {
return this.tupleMemory;
}
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 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -125,7 +125,7 @@
memory.getTupleMemory().add( leftTuple );
final Collection result = this.collect.instantiateResultObject();
- final Iterator it = memory.getObjectMemory().iterator( leftTuple );
+ final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
this.constraints.updateFromTuple( workingMemory,
leftTuple );
@@ -199,7 +199,7 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- memory.getObjectMemory().add( handle );
+ memory.getFactHandleMemory().add( handle );
final Iterator it = memory.getTupleMemory().iterator();
this.constraints.updateFromFactHandle( workingMemory,
@@ -227,7 +227,7 @@
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- if ( !memory.getObjectMemory().remove( handle ) ) {
+ if ( !memory.getFactHandleMemory().remove( handle ) ) {
return;
}
Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FactHandleMemory.java (from rev 7141, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java 2006-10-26 13:23:20 UTC (rev 7141)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/FactHandleMemory.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -0,0 +1,27 @@
+package org.drools.reteoo;
+
+import org.drools.common.InternalFactHandle;
+import org.drools.util.Entry;
+import org.drools.util.Iterator;
+
+public interface FactHandleMemory {
+ public Iterator iterator();
+
+ public Iterator iterator(ReteTuple tuple);
+
+ public boolean add(InternalFactHandle handle,
+ boolean checkExists);
+
+ public boolean add(InternalFactHandle handle);
+
+ public boolean remove(InternalFactHandle handle);
+
+ public boolean contains(InternalFactHandle handle);
+
+ public boolean isIndexed();
+
+ public int size();
+
+ public Entry[] getTable();
+
+}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/JoinNode.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -108,7 +108,7 @@
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getTupleMemory().add( leftTuple );
- final Iterator it = memory.getObjectMemory().iterator( leftTuple );
+ final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
this.constraints.updateFromTuple( workingMemory, leftTuple );
for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
final InternalFactHandle handle = entry.getFactHandle();
@@ -143,9 +143,9 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- memory.getObjectMemory().add( handle );
+ memory.getFactHandleMemory().add( handle );
- final Iterator it = memory.getTupleMemory().iterator();
+ final Iterator it = memory.getTupleMemory().iterator(handle);
this.constraints.updateFromFactHandle( workingMemory, handle );
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
@@ -172,11 +172,11 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- if ( !memory.getObjectMemory().remove( handle ) ) {
+ if ( !memory.getFactHandleMemory().remove( handle ) ) {
return;
}
- final Iterator it = memory.getTupleMemory().iterator();
+ final Iterator it = memory.getTupleMemory().iterator(handle);
this.constraints.updateFromFactHandle( workingMemory, handle );
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
@@ -209,7 +209,7 @@
return;
}
- final Iterator it = memory.getObjectMemory().iterator( leftTuple );
+ final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
this.constraints.updateFromTuple( workingMemory, leftTuple );
for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
final InternalFactHandle handle = entry.getFactHandle();
@@ -233,7 +233,7 @@
final Iterator tupleIter = memory.getTupleMemory().iterator();
for ( ReteTuple tuple = (ReteTuple) tupleIter.next(); tuple != null; tuple = (ReteTuple) tupleIter.next() ) {
- final Iterator objectIter = memory.getObjectMemory().iterator( tuple );
+ final Iterator objectIter = memory.getFactHandleMemory().iterator( tuple );
this.constraints.updateFromTuple( workingMemory, tuple );
for ( FactEntry entry = (FactEntry) objectIter.next(); entry != null; entry = (FactEntry) objectIter.next() ) {
final InternalFactHandle handle = entry.getFactHandle();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/MemoryVisitor.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -7,12 +7,12 @@
import org.drools.util.AbstractHashTable;
import org.drools.util.Entry;
import org.drools.util.FactHashTable;
-import org.drools.util.FieldIndexHashTable;
+import org.drools.util.FactHandleIndexHashTable;
import org.drools.util.Iterator;
import org.drools.util.ObjectHashMap;
import org.drools.util.ReflectiveVisitor;
import org.drools.util.TupleHashTable;
-import org.drools.util.FieldIndexHashTable.FieldIndexEntry;
+import org.drools.util.FactHandleIndexHashTable.FieldIndexEntry;
import org.drools.util.ObjectHashMap.ObjectEntry;
public class MemoryVisitor extends ReflectiveVisitor {
@@ -124,7 +124,7 @@
try {
final BetaMemory memory = (BetaMemory) this.workingMemory.getNodeMemory( node );
- checkObjectHashTable( memory.getObjectMemory() );
+ checkObjectHashTable( memory.getFactHandleMemory() );
checkTupleMemory( memory.getTupleMemory() );
} catch ( final Exception e ) {
e.printStackTrace();
@@ -149,7 +149,7 @@
System.out.println( indent() + node );
try {
final BetaMemory memory = (BetaMemory) this.workingMemory.getNodeMemory( node );
- checkObjectHashTable( memory.getObjectMemory() );
+ checkObjectHashTable( memory.getFactHandleMemory() );
checkTupleMemory( memory.getTupleMemory() );
} catch ( final Exception e ) {
e.printStackTrace();
@@ -191,11 +191,11 @@
// }
// }
- private void checkObjectHashTable(final ObjectHashTable memory) {
+ private void checkObjectHashTable(final FactHandleMemory memory) {
if ( memory instanceof FactHashTable ) {
checkFactHashTable( (FactHashTable) memory );
- } else if ( memory instanceof FieldIndexHashTable ) {
- checkFieldIndexHashTable( (FieldIndexHashTable) memory );
+ } else if ( memory instanceof FactHandleIndexHashTable ) {
+ checkFieldIndexHashTable( (FactHandleIndexHashTable) memory );
} else {
throw new RuntimeException( memory.getClass() + " should not be here" );
}
@@ -220,7 +220,7 @@
}
}
- private void checkFieldIndexHashTable(final FieldIndexHashTable memory) {
+ private void checkFieldIndexHashTable(final FactHandleIndexHashTable memory) {
final Entry[] entries = memory.getTable();
int factCount = 0;
int bucketCount = 0;
@@ -260,7 +260,7 @@
}
}
- private void checkTupleMemory(final TupleHashTable memory) {
+ private void checkTupleMemory(final TupleMemory memory) {
final Entry[] entries = memory.getTable();
int count = 0;
for ( int i = 0, length = entries.length; i < length; i++ ) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/NotNode.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -106,7 +106,7 @@
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
memory.getTupleMemory().add( leftTuple );
- final Iterator it = memory.getObjectMemory().iterator( leftTuple );
+ final Iterator it = memory.getFactHandleMemory().iterator( leftTuple );
this.constraints.updateFromTuple( workingMemory, leftTuple );
int matches = 0;
for ( FactEntry entry = (FactEntry) it.next(); entry != null; entry = (FactEntry) it.next() ) {
@@ -141,9 +141,9 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- memory.getObjectMemory().add( handle );
+ memory.getFactHandleMemory().add( handle );
- final Iterator it = memory.getTupleMemory().iterator();
+ final Iterator it = memory.getTupleMemory().iterator( handle );
this.constraints.updateFromFactHandle( workingMemory, handle );
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
@@ -176,11 +176,11 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( this );
- if ( !memory.getObjectMemory().remove( handle ) ) {
+ if ( !memory.getFactHandleMemory().remove( handle ) ) {
return;
}
- final Iterator it = memory.getTupleMemory().iterator();
+ final Iterator it = memory.getTupleMemory().iterator( handle );
this.constraints.updateFromFactHandle( workingMemory, handle );
for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
if ( this.constraints.isAllowedCachedRight( tuple ) ) {
Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectHashTable.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -1,27 +0,0 @@
-package org.drools.reteoo;
-
-import org.drools.common.InternalFactHandle;
-import org.drools.util.Entry;
-import org.drools.util.Iterator;
-
-public interface ObjectHashTable {
- public Iterator iterator();
-
- public Iterator iterator(ReteTuple tuple);
-
- public boolean add(InternalFactHandle handle,
- boolean checkExists);
-
- public boolean add(InternalFactHandle handle);
-
- public boolean remove(InternalFactHandle handle);
-
- public boolean contains(InternalFactHandle handle);
-
- public boolean isIndexed();
-
- public int size();
-
- public Entry[] getTable();
-
-}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/ObjectTypeNode.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -137,6 +137,9 @@
final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final FactHashTable memory = (FactHashTable) workingMemory.getNodeMemory( this );
+// if ( handle.getObject().getClass().getName().indexOf( "Edge" ) > 0 ) {
+// System.out.println( handle );
+// }
// checks if shadow is enabled
if ( this.objectType.isShadowEnabled() ) {
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleMemory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleMemory.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/TupleMemory.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -0,0 +1,24 @@
+package org.drools.reteoo;
+
+import org.drools.common.InternalFactHandle;
+import org.drools.util.Entry;
+import org.drools.util.Iterator;
+
+public interface TupleMemory {
+ public Iterator iterator();
+
+ public Iterator iterator(InternalFactHandle handle);
+
+ public void add(ReteTuple tuple);
+
+ public ReteTuple remove(ReteTuple tuple);
+
+ public boolean contains(ReteTuple tuple);
+
+ public boolean isIndexed();
+
+ public int size();
+
+ public Entry[] getTable();
+
+}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/AbstractHashTable.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -6,6 +6,8 @@
import java.io.Serializable;
import org.drools.common.InternalFactHandle;
+import org.drools.rule.Declaration;
+import org.drools.spi.FieldExtractor;
public abstract class AbstractHashTable
implements
@@ -353,4 +355,24 @@
return (object == this) || (this.handle == ((FactEntry) object).handle);
}
}
+
+ public static class FieldIndex {
+ public FieldExtractor extractor;
+ public Declaration declaration;
+
+ public FieldIndex(final FieldExtractor extractor,
+ final Declaration declaration) {
+ super();
+ this.extractor = extractor;
+ this.declaration = declaration;
+ }
+
+ public Declaration getDeclaration() {
+ return this.declaration;
+ }
+
+ public FieldExtractor getExtractor() {
+ return this.extractor;
+ }
+ }
}
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java (from rev 7141, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java 2006-10-26 13:23:20 UTC (rev 7141)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHandleIndexHashTable.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -0,0 +1,608 @@
+/**
+ *
+ */
+package org.drools.util;
+
+import org.drools.common.InternalFactHandle;
+import org.drools.reteoo.FactHandleMemory;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Declaration;
+import org.drools.spi.FieldExtractor;
+import org.drools.util.ObjectHashMap.ObjectEntry;
+
+public class FactHandleIndexHashTable extends AbstractHashTable
+ implements
+ FactHandleMemory {
+ public static final int PRIME = 31;
+
+ private int startResult;
+
+ private FieldIndexHashTableIterator tupleValueIterator;
+
+ private int factSize;
+
+ private Index index;
+
+ public FactHandleIndexHashTable(final FieldIndex[] index) {
+ this( 16,
+ 0.75f,
+ index );
+ }
+
+ public FactHandleIndexHashTable(final int capacity,
+ final float loadFactor,
+ final FieldIndex[] index) {
+ super( capacity,
+ loadFactor );
+
+ this.startResult = FactHandleIndexHashTable.PRIME;
+ for ( int i = 0, length = index.length; i < length; i++ ) {
+ this.startResult += FactHandleIndexHashTable.PRIME * this.startResult + index[i].getExtractor().getIndex();
+ }
+
+ switch ( index.length ) {
+ case 0 :
+ throw new IllegalArgumentException( "FieldIndexHashTable cannot use an index[] of length 0" );
+ case 1 :
+ this.index = new SingleIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ case 2 :
+ this.index = new DoubleCompositeIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ case 3 :
+ this.index = new TripleCompositeIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ default :
+ throw new IllegalArgumentException( "FieldIndexHashTable cannot use an index[] of length great than 3" );
+ }
+ }
+
+ public Iterator iterator() {
+ throw new UnsupportedOperationException( "FieldIndexHashTable does not support iterator()" );
+ }
+
+ public Iterator iterator(final ReteTuple tuple) {
+ if ( this.tupleValueIterator == null ) {
+ this.tupleValueIterator = new FieldIndexHashTableIterator();
+ }
+ final FieldIndexEntry entry = get( tuple );
+ this.tupleValueIterator.reset( (entry != null) ? entry.first : null );
+ return this.tupleValueIterator;
+ }
+
+ public boolean isIndexed() {
+ return true;
+ }
+
+ public Entry getBucket(final Object object) {
+ final int hashCode = this.index.hashCodeOf( object );
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ return this.table[index];
+ }
+
+ /**
+ * Fast re-usable iterator
+ *
+ */
+ public static class FieldIndexHashTableIterator
+ implements
+ Iterator {
+ private Entry entry;
+
+ public FieldIndexHashTableIterator() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.util.Iterator#next()
+ */
+ public Entry next() {
+ final Entry current = this.entry;
+ this.entry = (this.entry != null) ? this.entry.getNext() : null;
+ return current;
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.util.Iterator#reset()
+ */
+ public void reset(final Entry entry) {
+ this.entry = entry;
+ }
+ }
+
+ public boolean add(final InternalFactHandle handle) {
+ final FieldIndexEntry entry = getOrCreate( handle.getObject() );
+ entry.add( handle );
+ this.factSize++;
+ return true;
+ }
+
+ public boolean add(final InternalFactHandle handle,
+ final boolean checkExists) {
+ throw new UnsupportedOperationException( "FieldIndexHashTable does not support add(InternalFactHandle handle, boolean checkExists)" );
+ }
+
+ public boolean remove(final InternalFactHandle handle) {
+ final Object object = handle.getObject();
+ //this.index.setCachedValue( object );
+ final int hashCode = this.index.hashCodeOf( object );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ // search the table for the Entry, we need to track previous and next, so if the
+ // Entry is empty after its had the FactEntry removed, we must remove it from the table
+ FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
+ FieldIndexEntry current = previous;
+ while ( current != null ) {
+ final FieldIndexEntry next = (FieldIndexEntry) current.next;
+ if ( current.matches( object,
+ hashCode ) ) {
+ current.remove( handle );
+ this.factSize--;
+ // If the FactEntryIndex is empty, then remove it from the hash table
+ if ( current.first == null ) {
+ if ( previous == current ) {
+ this.table[index] = next;
+ } else {
+ previous.next = next;
+ }
+ current.next = null;
+ this.size--;
+ }
+ return true;
+ }
+ previous = current;
+ current = next;
+ }
+ return false;
+ }
+
+ public boolean contains(final InternalFactHandle handle) {
+ final Object object = handle.getObject();
+ //this.index.setCachedValue( object );
+
+ final int hashCode = this.index.hashCodeOf( object );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ FieldIndexEntry current = (FieldIndexEntry) this.table[index];
+ while ( current != null ) {
+ if ( current.matches( object,
+ hashCode ) ) {
+ return true;
+ }
+ current = (FieldIndexEntry) current.next;
+ }
+ return false;
+ }
+
+ public FieldIndexEntry get(final ReteTuple tuple) {
+ //this.index.setCachedValue( tuple );
+
+ final int hashCode = this.index.hashCodeOf( tuple );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+ FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
+
+ while ( entry != null ) {
+ if ( entry.matches( tuple,
+ hashCode ) ) {
+ return entry;
+ }
+ entry = (FieldIndexEntry) entry.getNext();
+ }
+
+ return entry;
+ }
+
+ /**
+ * We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did
+ * a get and then a create if the value is null.
+ *
+ * @param value
+ * @return
+ */
+ private FieldIndexEntry getOrCreate(final Object object) {
+ //this.index.setCachedValue( object );
+
+ final int hashCode = this.index.hashCodeOf( object );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+ FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
+
+ while ( entry != null ) {
+ if ( entry.matches( object,
+ hashCode ) ) {
+ return entry;
+ }
+ entry = (FieldIndexEntry) entry.next;
+ }
+
+ if ( entry == null ) {
+ entry = new FieldIndexEntry( this.index,
+ hashCode );
+ entry.next = this.table[index];
+ this.table[index] = entry;
+
+ if ( this.size++ >= this.threshold ) {
+ resize( 2 * this.table.length );
+ }
+ }
+ return entry;
+ }
+
+ public int size() {
+ return this.factSize;
+ }
+
+ public static class FieldIndexEntry
+ implements
+ Entry {
+ private Entry next;
+ private FactEntry first;
+ private final int hashCode;
+ private Index index;
+
+ public FieldIndexEntry(final Index index,
+ final int hashCode) {
+ this.index = index;
+ this.hashCode = hashCode;
+ }
+
+ public Entry getNext() {
+ return this.next;
+ }
+
+ public void setNext(final Entry next) {
+ this.next = next;
+ }
+
+ public FactEntry getFirst() {
+ return this.first;
+ }
+
+ public void add(final InternalFactHandle handle) {
+ final FactEntry entry = new FactEntry( handle );
+ entry.next = this.first;
+ this.first = entry;
+ }
+
+ public FactEntry get(final InternalFactHandle handle) {
+ final long id = handle.getId();
+ FactEntry current = this.first;
+ while ( current != null ) {
+ if ( current.handle.getId() == id ) {
+ return current;
+ }
+ current = (FactEntry) current.next;
+ }
+ return null;
+ }
+
+ public FactEntry remove(final InternalFactHandle handle) {
+ final long id = handle.getId();
+
+ FactEntry previous = this.first;
+ FactEntry current = previous;
+ while ( current != null ) {
+ final FactEntry next = (FactEntry) current.next;
+ if ( current.handle.getId() == id ) {
+ if ( this.first == current ) {
+ this.first = next;
+ } else {
+ previous.next = next;
+ }
+ current.next = null;
+ return current;
+ }
+ previous = current;
+ current = next;
+ }
+ return current;
+ }
+
+ // public boolean matches(int otherHashCode) {
+ // return this.hashCode == otherHashCode && this.index.equal( this.first.getFactHandle().getObject() );
+ // }
+
+ public boolean matches(final Object object,
+ final int objectHashCode) {
+ return this.hashCode == objectHashCode && this.index.equal( this.first.getFactHandle().getObject(),
+ object );
+ }
+
+ public boolean matches(final ReteTuple tuple,
+ final int tupleHashCode) {
+ return this.hashCode == tupleHashCode && this.index.equal( this.first.getFactHandle().getObject(),
+ tuple );
+ }
+
+ public int hashCode() {
+ return this.hashCode;
+ }
+
+ public boolean equals(final Object object) {
+ final FieldIndexEntry other = (FieldIndexEntry) object;
+ return this.hashCode == other.hashCode && this.index == other.index;
+ }
+ }
+
+ private static interface Index {
+ public int hashCodeOf(ReteTuple tuple);
+
+ public int hashCodeOf(Object object);
+
+ public boolean equal(Object object1,
+ Object object2);
+
+ public boolean equal(Object object1,
+ ReteTuple tuple);
+ }
+
+ private static class SingleIndex
+ implements
+ Index {
+ private FieldExtractor extractor;
+ private Declaration declaration;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public SingleIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.extractor = indexes[0].extractor;
+ this.declaration = indexes[0].declaration;
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+ final Object value = this.extractor.getValue( object );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+ final Object value = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ final Object value1 = this.extractor.getValue( object1 );
+ final Object value2 = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
+
+ return this.comparator.equal( value1,
+ value2 );
+ }
+
+ public boolean equal(final Object object1,
+ final Object object2) {
+
+ final Object value1 = this.extractor.getValue( object1 );
+ final Object value2 = this.extractor.getValue( object2 );
+
+ return this.comparator.equal( value1,
+ value2 );
+ }
+ }
+
+ private static class DoubleCompositeIndex
+ implements
+ Index {
+ private FieldIndex index0;
+ private FieldIndex index1;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public DoubleCompositeIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.index0 = indexes[0];
+ this.index1 = indexes[1];
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.extractor.getValue( object );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.extractor.getValue( object );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean equal(final Object object1,
+ final Object object2) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ private static class TripleCompositeIndex
+ implements
+ Index {
+ private FieldIndex index0;
+ private FieldIndex index1;
+ private FieldIndex index2;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public TripleCompositeIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.index0 = indexes[0];
+ this.index1 = indexes[1];
+ this.index2 = indexes[2];
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.extractor.getValue( object );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.extractor.getValue( object );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index2.extractor.getValue( object );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
+ hashCode += FactHandleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index2.extractor.getValue( object1 );
+ value2 = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean equal(final Object object1,
+ final Object object2) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index2.extractor.getValue( object1 );
+ value2 = this.index2.extractor.getValue( object2 );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FactHashTable.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -4,13 +4,13 @@
package org.drools.util;
import org.drools.common.InternalFactHandle;
-import org.drools.reteoo.ObjectHashTable;
+import org.drools.reteoo.FactHandleMemory;
import org.drools.reteoo.ReteTuple;
import org.drools.util.ObjectHashMap.ObjectEntry;
public class FactHashTable extends AbstractHashTable
implements
- ObjectHashTable {
+ FactHandleMemory {
private static final long serialVersionUID = 320L;
public FactHashTable() {
@@ -24,10 +24,6 @@
loadFactor );
}
- public Iterator iterator(final int hashCode) {
- throw new UnsupportedOperationException( "FactHashTable does not support the method iterator(int hashCode" );
- }
-
public Iterator iterator(final ReteTuple tuple) {
return iterator();
}
Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/FieldIndexHashTable.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -1,636 +0,0 @@
-/**
- *
- */
-package org.drools.util;
-
-import org.drools.common.InternalFactHandle;
-import org.drools.reteoo.ObjectHashTable;
-import org.drools.reteoo.ReteTuple;
-import org.drools.rule.Declaration;
-import org.drools.spi.FieldExtractor;
-import org.drools.util.ObjectHashMap.ObjectEntry;
-
-public class FieldIndexHashTable extends AbstractHashTable
- implements
- ObjectHashTable {
- public static final int PRIME = 31;
-
- private int startResult;
-
- private FieldIndexHashTableIterator tupleValueIterator;
-
- private int factSize;
-
- private Index index;
-
- public FieldIndexHashTable(final FieldIndex[] index) {
- this( 16,
- 0.75f,
- index );
- }
-
- public FieldIndexHashTable(final int capacity,
- final float loadFactor,
- final FieldIndex[] index) {
- super( capacity,
- loadFactor );
-
- this.startResult = FieldIndexHashTable.PRIME;
- for ( int i = 0, length = index.length; i < length; i++ ) {
- this.startResult += FieldIndexHashTable.PRIME * this.startResult + index[i].getExtractor().getIndex();
- }
-
- switch ( index.length ) {
- case 0 :
- throw new IllegalAccessError( "FieldIndexHashTable cannot use an index[] of length 0" );
- case 1 :
- this.index = new SingleIndex( index,
- this.startResult,
- this.comparator );
- break;
- case 2 :
- this.index = new DoubleCompositeIndex( index,
- this.startResult,
- this.comparator );
- break;
- case 3 :
- this.index = new TripleCompositeIndex( index,
- this.startResult,
- this.comparator );
- break;
- default :
- throw new IllegalAccessError( "FieldIndexHashTable cannot use an index[] of length great than 3" );
- }
- }
-
- public Iterator iterator() {
- throw new UnsupportedOperationException( "FieldIndexHashTable does not support iterator()" );
- }
-
- public Iterator iterator(final ReteTuple tuple) {
- if ( this.tupleValueIterator == null ) {
- this.tupleValueIterator = new FieldIndexHashTableIterator();
- }
- final FieldIndexEntry entry = get( tuple );
- this.tupleValueIterator.reset( (entry != null) ? entry.first : null );
- return this.tupleValueIterator;
- }
-
- public boolean isIndexed() {
- return true;
- }
-
- public Entry getBucket(final Object object) {
- final int hashCode = this.index.hashCodeOf( object );
- final int index = indexOf( hashCode,
- this.table.length );
-
- return this.table[index];
- }
-
- /**
- * Fast re-usable iterator
- *
- */
- public static class FieldIndexHashTableIterator
- implements
- Iterator {
- private Entry entry;
-
- public FieldIndexHashTableIterator() {
-
- }
-
- /* (non-Javadoc)
- * @see org.drools.util.Iterator#next()
- */
- public Entry next() {
- final Entry current = this.entry;
- this.entry = (this.entry != null) ? this.entry.getNext() : null;
- return current;
- }
-
- /* (non-Javadoc)
- * @see org.drools.util.Iterator#reset()
- */
- public void reset(final Entry entry) {
- this.entry = entry;
- }
- }
-
- public boolean add(final InternalFactHandle handle) {
- final FieldIndexEntry entry = getOrCreate( handle.getObject() );
- entry.add( handle );
- this.factSize++;
- return true;
- }
-
- public boolean add(final InternalFactHandle handle,
- final boolean checkExists) {
- throw new UnsupportedOperationException( "FieldIndexHashTable does not support add(InternalFactHandle handle, boolean checkExists)" );
- }
-
- public boolean remove(final InternalFactHandle handle) {
- final Object object = handle.getObject();
- //this.index.setCachedValue( object );
- final int hashCode = this.index.hashCodeOf( object );
-
- final int index = indexOf( hashCode,
- this.table.length );
-
- // search the table for the Entry, we need to track previous and next, so if the
- // Entry is empty after its had the FactEntry removed, we must remove it from the table
- FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
- FieldIndexEntry current = previous;
- while ( current != null ) {
- final FieldIndexEntry next = (FieldIndexEntry) current.next;
- if ( current.matches( object,
- hashCode ) ) {
- current.remove( handle );
- this.factSize--;
- // If the FactEntryIndex is empty, then remove it from the hash table
- if ( current.first == null ) {
- if ( previous == current ) {
- this.table[index] = next;
- } else {
- previous.next = next;
- }
- current.next = null;
- this.size--;
- }
- return true;
- }
- previous = current;
- current = next;
- }
- return false;
- }
-
- public boolean contains(final InternalFactHandle handle) {
- final Object object = handle.getObject();
- //this.index.setCachedValue( object );
-
- final int hashCode = this.index.hashCodeOf( object );
-
- final int index = indexOf( hashCode,
- this.table.length );
-
- FieldIndexEntry current = (FieldIndexEntry) this.table[index];
- while ( current != null ) {
- if ( current.matches( object,
- hashCode ) ) {
- return true;
- }
- current = (FieldIndexEntry) current.next;
- }
- return false;
- }
-
- public FieldIndexEntry get(final ReteTuple tuple) {
- //this.index.setCachedValue( tuple );
-
- final int hashCode = this.index.hashCodeOf( tuple );
-
- final int index = indexOf( hashCode,
- this.table.length );
- FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
-
- while ( entry != null ) {
- if ( entry.matches( tuple,
- hashCode ) ) {
- return entry;
- }
- entry = (FieldIndexEntry) entry.getNext();
- }
-
- return entry;
- }
-
- /**
- * We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did
- * a get and then a create if the value is null.
- *
- * @param value
- * @return
- */
- private FieldIndexEntry getOrCreate(final Object object) {
- //this.index.setCachedValue( object );
-
- final int hashCode = this.index.hashCodeOf( object );
-
- final int index = indexOf( hashCode,
- this.table.length );
- FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
-
- while ( entry != null ) {
- if ( entry.matches( object,
- hashCode ) ) {
- return entry;
- }
- entry = (FieldIndexEntry) entry.next;
- }
-
- if ( entry == null ) {
- entry = new FieldIndexEntry( this.index,
- hashCode );
- entry.next = this.table[index];
- this.table[index] = entry;
-
- if ( this.size++ >= this.threshold ) {
- resize( 2 * this.table.length );
- }
- }
- return entry;
- }
-
- public int size() {
- return this.factSize;
- }
-
- public static class FieldIndexEntry
- implements
- Entry {
- private Entry next;
- private FactEntry first;
- private final int hashCode;
- private Index index;
-
- public FieldIndexEntry(final Index index,
- final int hashCode) {
- this.index = index;
- this.hashCode = hashCode;
- }
-
- public Entry getNext() {
- return this.next;
- }
-
- public void setNext(final Entry next) {
- this.next = next;
- }
-
- public FactEntry getFirst() {
- return this.first;
- }
-
- public void add(final InternalFactHandle handle) {
- final FactEntry entry = new FactEntry( handle );
- entry.next = this.first;
- this.first = entry;
- }
-
- public FactEntry get(final InternalFactHandle handle) {
- final long id = handle.getId();
- FactEntry current = this.first;
- while ( current != null ) {
- if ( current.handle.getId() == id ) {
- return current;
- }
- current = (FactEntry) current.next;
- }
- return null;
- }
-
- public FactEntry remove(final InternalFactHandle handle) {
- final long id = handle.getId();
-
- FactEntry previous = this.first;
- FactEntry current = previous;
- while ( current != null ) {
- final FactEntry next = (FactEntry) current.next;
- if ( current.handle.getId() == id ) {
- if ( this.first == current ) {
- this.first = next;
- } else {
- previous.next = next;
- }
- current.next = null;
- return current;
- }
- previous = current;
- current = next;
- }
- return current;
- }
-
- // public boolean matches(int otherHashCode) {
- // return this.hashCode == otherHashCode && this.index.equal( this.first.getFactHandle().getObject() );
- // }
-
- public boolean matches(final Object object,
- final int objectHashCode) {
- return this.hashCode == objectHashCode && this.index.equal( this.first.getFactHandle().getObject(),
- object );
- }
-
- public boolean matches(final ReteTuple tuple,
- final int tupleHashCode) {
- return this.hashCode == tupleHashCode && this.index.equal( this.first.getFactHandle().getObject(),
- tuple );
- }
-
- public int hashCode() {
- return this.hashCode;
- }
-
- public boolean equals(final Object object) {
- final FieldIndexEntry other = (FieldIndexEntry) object;
- return this.hashCode == other.hashCode && this.index == other.index;
- }
- }
-
- private static interface Index {
- public int hashCodeOf(ReteTuple tuple);
-
- public int hashCodeOf(Object object);
-
- public boolean equal(Object object1,
- Object object2);
-
- public boolean equal(Object object1,
- ReteTuple tuple);
- }
-
- private static class SingleIndex
- implements
- Index {
- private FieldExtractor extractor;
- private Declaration declaration;
-
- private int startResult;
-
- private ObjectComparator comparator;
-
- public SingleIndex(final FieldIndex[] indexes,
- final int startResult,
- final ObjectComparator comparator) {
- this.startResult = startResult;
-
- this.extractor = indexes[0].extractor;
- this.declaration = indexes[0].declaration;
-
- this.comparator = comparator;
- }
-
- public int hashCodeOf(final Object object) {
- int hashCode = this.startResult;
- final Object value = this.extractor.getValue( object );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
- return this.comparator.rehash( hashCode );
- }
-
- public int hashCodeOf(final ReteTuple tuple) {
- int hashCode = this.startResult;
- final Object value = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
- return this.comparator.rehash( hashCode );
- }
-
- public boolean equal(final Object object1,
- final ReteTuple tuple) {
- final Object value1 = this.extractor.getValue( object1 );
- final Object value2 = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
-
- return this.comparator.equal( value1,
- value2 );
- }
-
- public boolean equal(final Object object1,
- final Object object2) {
-
- final Object value1 = this.extractor.getValue( object1 );
- final Object value2 = this.extractor.getValue( object2 );
-
- return this.comparator.equal( value1,
- value2 );
- }
- }
-
- private static class DoubleCompositeIndex
- implements
- Index {
- private FieldIndex index0;
- private FieldIndex index1;
-
- private int startResult;
-
- private ObjectComparator comparator;
-
- public DoubleCompositeIndex(final FieldIndex[] indexes,
- final int startResult,
- final ObjectComparator comparator) {
- this.startResult = startResult;
-
- this.index0 = indexes[0];
- this.index1 = indexes[1];
-
- this.comparator = comparator;
- }
-
- public int hashCodeOf(final Object object) {
- int hashCode = this.startResult;
-
- Object value = this.index0.extractor.getValue( object );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = this.index1.extractor.getValue( object );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- return this.comparator.rehash( hashCode );
- }
-
- public int hashCodeOf(final ReteTuple tuple) {
- int hashCode = this.startResult;
-
- Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- return this.comparator.rehash( hashCode );
- }
-
- public boolean equal(final Object object1,
- final ReteTuple tuple) {
- Object value1 = this.index0.extractor.getValue( object1 );
- Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = this.index1.extractor.getValue( object1 );
- value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
-
- public boolean equal(final Object object1,
- final Object object2) {
- Object value1 = this.index0.extractor.getValue( object1 );
- Object value2 = this.index0.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = this.index1.extractor.getValue( object1 );
- value2 = this.index1.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
- }
-
- private static class TripleCompositeIndex
- implements
- Index {
- private FieldIndex index0;
- private FieldIndex index1;
- private FieldIndex index2;
-
- private int startResult;
-
- private ObjectComparator comparator;
-
- public TripleCompositeIndex(final FieldIndex[] indexes,
- final int startResult,
- final ObjectComparator comparator) {
- this.startResult = startResult;
-
- this.index0 = indexes[0];
- this.index1 = indexes[1];
- this.index2 = indexes[2];
-
- this.comparator = comparator;
- }
-
- public int hashCodeOf(final Object object) {
- int hashCode = this.startResult;
-
- Object value = this.index0.extractor.getValue( object );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = this.index1.extractor.getValue( object );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = this.index2.extractor.getValue( object );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- return this.comparator.rehash( hashCode );
- }
-
- public int hashCodeOf(final ReteTuple tuple) {
- int hashCode = this.startResult;
-
- Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- value = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
- hashCode += FieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
-
- return this.comparator.rehash( hashCode );
- }
-
- public boolean equal(final Object object1,
- final ReteTuple tuple) {
- Object value1 = this.index0.extractor.getValue( object1 );
- Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = this.index1.extractor.getValue( object1 );
- value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = this.index2.extractor.getValue( object1 );
- value2 = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
-
- public boolean equal(final Object object1,
- final Object object2) {
- Object value1 = this.index0.extractor.getValue( object1 );
- Object value2 = this.index0.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = this.index1.extractor.getValue( object1 );
- value2 = this.index1.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- value1 = this.index2.extractor.getValue( object1 );
- value2 = this.index2.extractor.getValue( object2 );
-
- if ( !this.comparator.equal( value1,
- value2 ) ) {
- return false;
- }
-
- return true;
- }
- }
-
- public static class FieldIndex {
- private FieldExtractor extractor;
- private Declaration declaration;
-
- public FieldIndex(final FieldExtractor extractor,
- final Declaration declaration) {
- super();
- this.extractor = extractor;
- this.declaration = declaration;
- }
-
- public Declaration getDeclaration() {
- return this.declaration;
- }
-
- public void setDeclaration(final Declaration declaration) {
- this.declaration = declaration;
- }
-
- public FieldExtractor getExtractor() {
- return this.extractor;
- }
-
- public void setExtractor(final FieldExtractor extractor) {
- this.extractor = extractor;
- }
- }
-}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleHashTable.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -3,9 +3,11 @@
*/
package org.drools.util;
+import org.drools.common.InternalFactHandle;
import org.drools.reteoo.ReteTuple;
+import org.drools.reteoo.TupleMemory;
-public class TupleHashTable extends AbstractHashTable {
+public class TupleHashTable extends AbstractHashTable implements TupleMemory {
public TupleHashTable() {
this( 16,
0.75f );
@@ -16,8 +18,12 @@
super( capacity,
loadFactor );
}
+
+ public Iterator iterator(final InternalFactHandle handle) {
+ return iterator();
+ }
- public Object add(final ReteTuple tuple) {
+ public void add(final ReteTuple tuple) {
final int hashCode = tuple.hashCode();
final int index = indexOf( hashCode,
this.table.length );
@@ -28,10 +34,9 @@
if ( this.size++ >= this.threshold ) {
resize( 2 * this.table.length );
}
- return null;
}
- public Object get(final ReteTuple tuple) {
+ public ReteTuple get(final ReteTuple tuple) {
final int hashCode = tuple.hashCode();
final int index = indexOf( hashCode,
this.table.length );
@@ -46,7 +51,7 @@
return null;
}
- public Object remove(final ReteTuple tuple) {
+ public ReteTuple remove(final ReteTuple tuple) {
final int hashCode = tuple.hashCode();
final int index = indexOf( hashCode,
this.table.length );
@@ -82,4 +87,8 @@
public boolean contains(final ReteTuple tuple) {
return (get( tuple ) != null);
}
+
+ public boolean isIndexed() {
+ return false;
+ }
}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/TupleIndexHashTable.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -0,0 +1,595 @@
+/**
+ *
+ */
+package org.drools.util;
+
+import org.drools.common.InternalFactHandle;
+import org.drools.reteoo.FactHandleMemory;
+import org.drools.reteoo.ReteTuple;
+import org.drools.reteoo.TupleMemory;
+import org.drools.rule.Column;
+import org.drools.rule.Declaration;
+import org.drools.spi.FieldExtractor;
+import org.drools.util.ObjectHashMap.ObjectEntry;
+
+public class TupleIndexHashTable extends AbstractHashTable
+ implements
+ TupleMemory {
+ public static final int PRIME = 31;
+
+ private int startResult;
+
+ private FieldIndexHashTableIterator tupleValueIterator;
+
+ private int factSize;
+
+ private Index index;
+
+ public TupleIndexHashTable(final FieldIndex[] index) {
+ this( 16,
+ 0.75f,
+ index );
+ }
+
+ public TupleIndexHashTable(final int capacity,
+ final float loadFactor,
+ final FieldIndex[] index) {
+ super( capacity,
+ loadFactor );
+
+ this.startResult = TupleIndexHashTable.PRIME;
+ for ( int i = 0, length = index.length; i < length; i++ ) {
+ this.startResult += TupleIndexHashTable.PRIME * this.startResult + index[i].getExtractor().getIndex();
+ }
+
+ switch ( index.length ) {
+ case 0 :
+ throw new IllegalArgumentException( "FieldIndexHashTable cannot use an index[] of length 0" );
+ case 1 :
+ this.index = new SingleIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ case 2 :
+ this.index = new DoubleCompositeIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ case 3 :
+ this.index = new TripleCompositeIndex( index,
+ this.startResult,
+ this.comparator );
+ break;
+ default :
+ throw new IllegalArgumentException( "FieldIndexHashTable cannot use an index[] of length great than 3" );
+ }
+ }
+
+ public Iterator iterator() {
+ throw new UnsupportedOperationException( "FieldIndexHashTable does not support iterator()" );
+ }
+
+ public Iterator iterator(final InternalFactHandle handle) {
+ if ( this.tupleValueIterator == null ) {
+ this.tupleValueIterator = new FieldIndexHashTableIterator();
+ }
+ final FieldIndexEntry entry = get( handle );
+ this.tupleValueIterator.reset( (entry != null) ? entry.first : null );
+ return this.tupleValueIterator;
+ }
+
+ public boolean isIndexed() {
+ return true;
+ }
+
+ public Entry getBucket(final Object object) {
+ final int hashCode = this.index.hashCodeOf( object );
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ return this.table[index];
+ }
+
+ /**
+ * Fast re-usable iterator
+ *
+ */
+ public static class FieldIndexHashTableIterator
+ implements
+ Iterator {
+ private Entry entry;
+
+ public FieldIndexHashTableIterator() {
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.util.Iterator#next()
+ */
+ public Entry next() {
+ final Entry current = this.entry;
+ this.entry = (this.entry != null) ? this.entry.getNext() : null;
+ return current;
+ }
+
+ /* (non-Javadoc)
+ * @see org.drools.util.Iterator#reset()
+ */
+ public void reset(final Entry entry) {
+ this.entry = entry;
+ }
+ }
+
+ public void add(final ReteTuple tuple) {
+ final FieldIndexEntry entry = getOrCreate( tuple );
+ entry.add( tuple );
+ this.factSize++;
+ }
+
+ public boolean add(final ReteTuple tuple,
+ final boolean checkExists) {
+ throw new UnsupportedOperationException( "FieldIndexHashTable does not support add(ReteTuple tuple, boolean checkExists)" );
+ }
+
+ public ReteTuple remove(final ReteTuple tuple) {
+ final int hashCode = this.index.hashCodeOf( tuple );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ // search the table for the Entry, we need to track previous and next, so if the
+ // Entry is empty after its had the FactEntry removed, we must remove it from the table
+ FieldIndexEntry previous = (FieldIndexEntry) this.table[index];
+ FieldIndexEntry current = previous;
+ while ( current != null ) {
+ final FieldIndexEntry next = (FieldIndexEntry) current.next;
+ if ( current.matches( tuple,
+ hashCode ) ) {
+ ReteTuple old = current.remove( tuple );
+ this.factSize--;
+ // If the FactEntryIndex is empty, then remove it from the hash table
+ if ( current.first == null ) {
+ if ( previous == current ) {
+ this.table[index] = next;
+ } else {
+ previous.next = next;
+ }
+ current.next = null;
+ this.size--;
+ }
+ return old;
+ }
+ previous = current;
+ current = next;
+ }
+ return null;
+ }
+
+ public boolean contains(final ReteTuple tuple) {
+ final int hashCode = this.index.hashCodeOf( tuple );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+
+ FieldIndexEntry current = (FieldIndexEntry) this.table[index];
+ while ( current != null ) {
+ if ( current.matches( tuple,
+ hashCode ) ) {
+ return true;
+ }
+ current = (FieldIndexEntry) current.next;
+ }
+ return false;
+ }
+
+ public FieldIndexEntry get(final InternalFactHandle handle) {
+ Object object = handle.getObject();
+ final int hashCode = this.index.hashCodeOf( handle.getObject() );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+ FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
+
+ while ( entry != null ) {
+ if ( entry.matches( object,
+ hashCode ) ) {
+ return entry;
+ }
+ entry = (FieldIndexEntry) entry.getNext();
+ }
+
+ return entry;
+ }
+
+ /**
+ * We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did
+ * a get and then a create if the value is null.
+ *
+ * @param value
+ * @return
+ */
+ private FieldIndexEntry getOrCreate(final ReteTuple tuple) {
+ final int hashCode = this.index.hashCodeOf( tuple );
+
+ final int index = indexOf( hashCode,
+ this.table.length );
+ FieldIndexEntry entry = (FieldIndexEntry) this.table[index];
+
+ while ( entry != null ) {
+ if ( entry.matches( tuple,
+ hashCode ) ) {
+ return entry;
+ }
+ entry = (FieldIndexEntry) entry.next;
+ }
+
+ if ( entry == null ) {
+ entry = new FieldIndexEntry( this.index,
+ hashCode );
+ entry.next = this.table[index];
+ this.table[index] = entry;
+
+ if ( this.size++ >= this.threshold ) {
+ resize( 2 * this.table.length );
+ }
+ }
+ return entry;
+ }
+
+ public int size() {
+ return this.factSize;
+ }
+
+ public static class FieldIndexEntry
+ implements
+ Entry {
+ private Entry next;
+ private ReteTuple first;
+ private final int hashCode;
+ private Index index;
+
+ public FieldIndexEntry(final Index index,
+ final int hashCode) {
+ this.index = index;
+ this.hashCode = hashCode;
+ }
+
+ public Entry getNext() {
+ return this.next;
+ }
+
+ public void setNext(final Entry next) {
+ this.next = next;
+ }
+
+ public ReteTuple getFirst() {
+ return this.first;
+ }
+
+ public void add(final ReteTuple tuple) {
+ tuple.setNext( this.first );
+ this.first = tuple;
+ }
+
+ public ReteTuple get(final ReteTuple tuple) {
+ ReteTuple current = this.first;
+ while ( current != null ) {
+ if ( tuple.equals( current ) ) {
+ return current;
+ }
+ current = (ReteTuple) current.getNext();
+ }
+ return null;
+ }
+
+ public ReteTuple remove(final ReteTuple tuple) {
+ ReteTuple previous = this.first;
+ ReteTuple current = previous;
+ while ( current != null ) {
+ final ReteTuple next = (ReteTuple) current.getNext();
+ if ( tuple.equals( current ) ) {
+ if ( this.first == current ) {
+ this.first = next;
+ } else {
+ previous.setNext( next );
+ }
+ current.setNext( null );
+ return current;
+ }
+ previous = current;
+ current = next;
+ }
+ return current;
+ }
+
+ // public boolean matches(int otherHashCode) {
+ // return this.hashCode == otherHashCode && this.index.equal( this.first.getFactHandle().getObject() );
+ // }
+
+ public boolean matches(final Object object,
+ final int objectHashCode) {
+ return this.hashCode == objectHashCode && this.index.equal( object,
+ this.first );
+ }
+
+ public boolean matches(final ReteTuple tuple,
+ final int tupleHashCode) {
+ return this.hashCode == tupleHashCode && this.index.equal( this.first,
+ tuple );
+ }
+
+ public int hashCode() {
+ return this.hashCode;
+ }
+
+ public boolean equals(final Object object) {
+ final FieldIndexEntry other = (FieldIndexEntry) object;
+ return this.hashCode == other.hashCode && this.index == other.index;
+ }
+ }
+
+ private static interface Index {
+ public int hashCodeOf(ReteTuple tuple);
+
+ public int hashCodeOf(Object object);
+
+ public boolean equal(Object object,
+ ReteTuple tuple);
+
+ public boolean equal(ReteTuple tuple1,
+ ReteTuple tuple2);
+ }
+
+ private static class SingleIndex
+ implements
+ Index {
+ private FieldExtractor extractor;
+ private Declaration declaration;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public SingleIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.extractor = indexes[0].extractor;
+ this.declaration = indexes[0].declaration;
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+ final Object value = this.extractor.getValue( object );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+ final Object value = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ final Object value1 = this.extractor.getValue( object1 );
+ final Object value2 = this.declaration.getValue( tuple.get( this.declaration ).getObject() );
+
+ return this.comparator.equal( value1,
+ value2 );
+ }
+
+ public boolean equal(final ReteTuple tuple1,
+ final ReteTuple tuple2) {
+ final Object value1 = this.declaration.getValue( tuple1.get( this.declaration ).getObject() );
+ final Object value2 = this.declaration.getValue( tuple2.get( this.declaration ).getObject() );
+ return this.comparator.equal( value1,
+ value2 );
+ }
+ }
+
+ private static class DoubleCompositeIndex
+ implements
+ Index {
+ private FieldIndex index0;
+ private FieldIndex index1;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public DoubleCompositeIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.index0 = indexes[0];
+ this.index1 = indexes[1];
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.extractor.getValue( object );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.extractor.getValue( object );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean equal(final ReteTuple tuple1,
+ final ReteTuple tuple2) {
+ Object value1 = this.index0.declaration.getValue( tuple1.get( this.index0.declaration ).getObject() );
+ Object value2 = this.index0.declaration.getValue( tuple2.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.declaration.getValue( tuple1.get( this.index1.declaration ).getObject() );
+ value2 = this.index1.declaration.getValue( tuple2.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ private static class TripleCompositeIndex
+ implements
+ Index {
+ private FieldIndex index0;
+ private FieldIndex index1;
+ private FieldIndex index2;
+
+ private int startResult;
+
+ private ObjectComparator comparator;
+
+ public TripleCompositeIndex(final FieldIndex[] indexes,
+ final int startResult,
+ final ObjectComparator comparator) {
+ this.startResult = startResult;
+
+ this.index0 = indexes[0];
+ this.index1 = indexes[1];
+ this.index2 = indexes[2];
+
+ this.comparator = comparator;
+ }
+
+ public int hashCodeOf(final Object object) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.extractor.getValue( object );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.extractor.getValue( object );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index2.extractor.getValue( object );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public int hashCodeOf(final ReteTuple tuple) {
+ int hashCode = this.startResult;
+
+ Object value = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ value = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
+ hashCode += TupleIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
+
+ return this.comparator.rehash( hashCode );
+ }
+
+ public boolean equal(final Object object1,
+ final ReteTuple tuple) {
+ Object value1 = this.index0.extractor.getValue( object1 );
+ Object value2 = this.index0.declaration.getValue( tuple.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.extractor.getValue( object1 );
+ value2 = this.index1.declaration.getValue( tuple.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index2.extractor.getValue( object1 );
+ value2 = this.index2.declaration.getValue( tuple.get( this.index2.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public boolean equal(final ReteTuple tuple1,
+ final ReteTuple tuple2) {
+ Object value1 = this.index0.declaration.getValue( tuple1.get( this.index0.declaration ).getObject() );
+ Object value2 = this.index0.declaration.getValue( tuple2.get( this.index0.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index1.declaration.getValue( tuple1.get( this.index1.declaration ).getObject() );
+ value2 = this.index1.declaration.getValue( tuple2.get( this.index1.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ value1 = this.index2.declaration.getValue( tuple1.get( this.index2.declaration ).getObject() );
+ value2 = this.index2.declaration.getValue( tuple2.get( this.index2.declaration ).getObject() );
+
+ if ( !this.comparator.equal( value1,
+ value2 ) ) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
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 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/CollectNodeTest.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -89,7 +89,7 @@
assertEquals( 0,
this.memory.getTupleMemory().size() );
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
}
/* (non-Javadoc)
@@ -138,7 +138,7 @@
assertEquals( 1,
this.memory.getTupleMemory().size() );
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
Assert.assertTrue( "An empty collection should be propagated",
((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
@@ -186,7 +186,7 @@
assertEquals( 1,
this.memory.getTupleMemory().size() );
assertEquals( 2,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
2,
((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).size() );
@@ -226,7 +226,7 @@
assertEquals( 1,
this.memory.getTupleMemory().size() );
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
Assert.assertTrue( "An empty collection should be propagated",
((Collection) ((DefaultFactHandle) ((Tuple) ((Object[]) this.sink.getAsserted().get( 0 ))[0]).get( 1 )).getObject()).isEmpty() );
@@ -264,7 +264,7 @@
this.context,
this.workingMemory );
assertEquals( 1,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
assertEquals( 2,
this.sink.getAsserted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
@@ -276,7 +276,7 @@
this.workingMemory );
assertEquals( 2,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
assertEquals( 3,
this.sink.getAsserted().size() );
Assert.assertEquals( "Wrong number of elements in matching objects list ",
@@ -298,7 +298,7 @@
this.context,
this.workingMemory );
assertEquals( 2,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
// assert tuple, should add one to left memory
this.node.assertTuple( tuple0,
@@ -320,7 +320,7 @@
this.context,
this.workingMemory );
assertEquals( 1,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
assertEquals( 1,
this.sink.getRetracted().size() );
assertEquals( 2,
@@ -333,7 +333,7 @@
this.context,
this.workingMemory );
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
assertEquals( 2,
this.sink.getRetracted().size() );
assertEquals( 3,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/FromNodeTest.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -273,7 +273,7 @@
final BetaMemory memory = (BetaMemory) workingMemory.getNodeMemory( from );
assertEquals( 1,
memory.getTupleMemory().size() );
- assertNull( memory.getObjectMemory() );
+ assertNull( memory.getFactHandleMemory() );
assertEquals( 2,
((LinkedList) memory.getCreatedHandles().get( tuple )).size() );
@@ -287,7 +287,7 @@
workingMemory );
assertEquals( 0,
memory.getTupleMemory().size() );
- assertNull( memory.getObjectMemory() );
+ assertNull( memory.getFactHandleMemory() );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/JoinNodeTest.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -73,7 +73,7 @@
assertEquals( 0,
this.memory.getTupleMemory().size() );
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
}
@@ -144,7 +144,7 @@
assertEquals( 1,
this.memory.getTupleMemory().size() );
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
// assert tuple, should add left memory should be 2
final DefaultFactHandle f1 = new DefaultFactHandle( 1,
@@ -178,7 +178,7 @@
assertEquals( 0,
this.memory.getTupleMemory().size() );
assertEquals( 1,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
// check new objects/handles still assert
final DefaultFactHandle f1 = (DefaultFactHandle) this.workingMemory.assertObject( "test1" );
@@ -186,9 +186,9 @@
this.context,
this.workingMemory );
assertEquals( 2,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
- final Iterator it = this.memory.getObjectMemory().iterator( new ReteTuple( f0 ) );
+ final Iterator it = this.memory.getFactHandleMemory().iterator( new ReteTuple( f0 ) );
final InternalFactHandle rf0 = ((FactEntry) it.next()).getFactHandle();
final InternalFactHandle rf1 = ((FactEntry) it.next()).getFactHandle();
@@ -297,7 +297,7 @@
// Double check the item is in memory
final BetaMemory memory = (BetaMemory) this.workingMemory.getNodeMemory( this.node );
- assertTrue( memory.getObjectMemory().contains( f0 ) );
+ assertTrue( memory.getFactHandleMemory().contains( f0 ) );
// Retract an object, check propagations and memory
this.node.retractObject( f0,
@@ -316,7 +316,7 @@
f0 ) ) );
// Now check the item is no longer in memory
- assertFalse( memory.getObjectMemory().contains( f0 ) );
+ assertFalse( memory.getFactHandleMemory().contains( f0 ) );
this.node.retractTuple( tuple2,
this.context,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/NotNodeTest.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -141,7 +141,7 @@
assertEquals( 2,
this.memory.getTupleMemory().size() );
assertEquals( 1,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
// When this is retracter both tuples should assert
this.node.retractObject( f1,
@@ -241,14 +241,14 @@
// Initially, no objects in right memory
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
this.node.assertObject( f1,
this.context,
this.workingMemory );
// Now, needs to have 1 object in right memory
assertEquals( 1,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
// simulate modify
this.node.retractObject( f1,
@@ -259,14 +259,14 @@
this.workingMemory );
// Memory should not change
assertEquals( 1,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
// When this is retracter both tuples should assert
this.node.retractObject( f1,
this.context,
this.workingMemory );
assertEquals( 0,
- this.memory.getObjectMemory().size() );
+ this.memory.getFactHandleMemory().size() );
// check memory sizes
assertEquals( 1,
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexEntryTest.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -7,7 +7,7 @@
import org.drools.common.DefaultFactHandle;
import org.drools.common.InternalFactHandle;
import org.drools.util.AbstractHashTable.FactEntry;
-import org.drools.util.FieldIndexHashTable.FieldIndexEntry;
+import org.drools.util.FactHandleIndexHashTable.FieldIndexEntry;
public class FieldIndexEntryTest extends TestCase {
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java 2006-10-26 19:21:06 UTC (rev 7150)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/FieldIndexHashTableTest.java 2006-10-26 19:50:28 UTC (rev 7151)
@@ -16,7 +16,7 @@
import org.drools.rule.Declaration;
import org.drools.spi.FieldExtractor;
import org.drools.util.AbstractHashTable.FactEntry;
-import org.drools.util.FieldIndexHashTable.FieldIndexEntry;
+import org.drools.util.FactHandleIndexHashTable.FieldIndexEntry;
import org.drools.util.ObjectHashMap.ObjectEntry;
public class FieldIndexHashTableTest extends TestCase {
@@ -32,7 +32,7 @@
extractor,
column );
- final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( extractor,
declaration );
final Cheese cheddar = new Cheese( "cheddar",
@@ -77,7 +77,7 @@
extractor,
column );
- final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( extractor,
declaration );
assertEquals( 0,
@@ -130,7 +130,7 @@
extractor,
column );
- final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( extractor,
declaration );
assertEquals( 0,
@@ -184,7 +184,7 @@
extractor,
column );
- final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( extractor,
declaration );
final TestClass c1 = new TestClass( 0,
@@ -231,7 +231,7 @@
extractor,
column );
- final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( extractor,
declaration );
assertEquals( 0,
@@ -295,7 +295,7 @@
extractor,
column );
- final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( extractor,
declaration );
assertEquals( 0,
@@ -508,7 +508,7 @@
extractor,
column );
- final FieldIndexHashTable map = new FieldIndexHashTable( extractor,
+ final FactHandleIndexHashTable map = new FactHandleIndexHashTable( extractor,
declaration );
final Cheese stilton = new Cheese( "stilton",
More information about the jboss-svn-commits
mailing list