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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 18 19:55:16 EDT 2006


Author: mark.proctor at jboss.com
Date: 2006-10-18 19:55:15 -0400 (Wed, 18 Oct 2006)
New Revision: 6905

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java
Log:
JBRULES-526 Implement a CompositeIndex for Facts
-Unrolled  the  loops, works correctly now

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java	2006-10-18 23:24:16 UTC (rev 6904)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/util/CompositeFieldIndexHashTable.java	2006-10-18 23:55:15 UTC (rev 6905)
@@ -52,10 +52,7 @@
             case 2 :
                 this.index = new DoubleCompositeIndex( index,
                                                        this.startResult,
-                                                       this.comparator );
-//                this.index = new DefaultCompositeIndex( index,
-//                                                        this.startResult,
-//                                                        this.comparator );                    
+                                                       this.comparator );                   
                 break;
             case 3 :
                 this.index = new TripleCompositeIndex( index,
@@ -436,7 +433,8 @@
         Index {
         private FieldIndex       index0;
         private FieldIndex       index1;
-
+        
+        
         private int              startResult;
 
         private ObjectComparator comparator;
@@ -457,7 +455,7 @@
 
         public int hashCodeOf(Object object) {
             int hashCode = startResult;
-
+            
             Object value = index0.extractor.getValue( object );
             hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode());
 
@@ -468,15 +466,15 @@
         }
 
         public int hashCodeOf(ReteTuple tuple) {
-            int hashCode = startResult;
+            int hashCode = startResult;           
 
             Object value = index0.declaration.getValue( tuple.get( index0.declaration ).getObject() );
-            hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : this.comparator.hashCodeOf( value ));
+            hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode() );
 
             value = index1.declaration.getValue( tuple.get( index1.declaration ).getObject() );
-            hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : this.comparator.hashCodeOf( value ));
+            hashCode += CompositeFieldIndexHashTable.PRIME * hashCode + ((value == null) ? 0 : value.hashCode() );
 
-            return hashCode;
+            return this.comparator.rehash( hashCode );
         }
 
         //        public void setCachedValue(Object object) {
@@ -518,7 +516,7 @@
         }
 
         public boolean equal(Object object1,
-                             Object object2) {
+                             Object object2) {         
             Object value1 = index0.extractor.getValue( object1 );
             Object value2 = index0.extractor.getValue( object2 );
 
@@ -681,11 +679,11 @@
         private int              startResult;
         private ObjectComparator comparator;
 
-        public DefaultCompositeIndex(FieldIndex[] fieldIndex,
+        public DefaultCompositeIndex(FieldIndex[] fieldIndexes,
                                      int startResult,
                                      ObjectComparator comparator) {
             this.startResult = startResult;
-            this.indexes = fieldIndex;
+            this.indexes = fieldIndexes;
             this.comparator = comparator;
         }
 




More information about the jboss-svn-commits mailing list