inlined a getKey and get op in sendFeedback
authorjjenista <jjenista>
Tue, 17 Nov 2009 00:14:04 +0000 (00:14 +0000)
committerjjenista <jjenista>
Tue, 17 Nov 2009 00:14:04 +0000 (00:14 +0000)
Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java
Robust/src/Benchmarks/Distributed/SpamFilter/HashEntry.java
Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java

index 8ea2010a7089f71c718ccfb147ee9320265769cd..b018bfc524a981c022adb4c4042caced38e1c7d5 100644 (file)
@@ -1,6 +1,6 @@
 public class DistributedHashMap {
-  DistributedHashEntry[] table;
-  float loadFactor;
+  public DistributedHashEntry[] table;
+  public float loadFactor;
 
   public DistributedHashMap(int initialCapacity, float loadFactor) {
     init(initialCapacity, loadFactor);
@@ -19,13 +19,14 @@ public class DistributedHashMap {
       return value;
   }
 
+  /*
   Object remove(Object key) {
     int hashcode=key.hashCode();
     int index1=hash1(hashcode, table.length);
     DistributedHashEntry dhe=table[index1];
     if (dhe==null)
       return null;
-    DHashEntry ptr=dhe.array;
+    HashEntry ptr=dhe.array;
 
     if (ptr!=null) {
       if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
@@ -54,7 +55,7 @@ public class DistributedHashMap {
     if (dhe==null)
       return null;
 
-    DHashEntry ptr=dhe.array;
+    HashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode
@@ -75,7 +76,7 @@ public class DistributedHashMap {
     if (dhe==null)
       return null;
 
-    DHashEntry ptr=dhe.array;
+    HashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode
@@ -94,7 +95,7 @@ public class DistributedHashMap {
     if (dhe==null)
       return false;
 
-    DHashEntry ptr=dhe.array;
+    HashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode
@@ -114,7 +115,7 @@ public class DistributedHashMap {
        dhe=global new DistributedHashEntry();
        table[index1]=dhe;
     }
-    DHashEntry ptr=dhe.array;
+    HashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
@@ -125,7 +126,7 @@ public class DistributedHashMap {
       ptr=ptr.next;
     }
 
-    DHashEntry he=global new DHashEntry();
+    HashEntry he=global new HashEntry();
     he.value=value;
     he.key=key;
     he.hashval=hashcode;
@@ -136,6 +137,7 @@ public class DistributedHashMap {
     
     return null;
   }
+  */
 }
 
 class DistributedHashEntry {
@@ -147,10 +149,10 @@ class DistributedHashEntry {
 
 
 class DHashEntry {
-  public DHashEntry() {
+  public HashEntry() {
   }
   int hashval;
-  Object key;
-  Object value;
+  HashEntry key;
+  FilterStatistic value;
   DHashEntry next;
 }
index 2021a691989a859fded3ce782ed13164bf0f8b6a..7b391f8cdae952ea2e48ba32d5bcb3d31956d995 100644 (file)
@@ -2,7 +2,9 @@ public class HashEntry {
   GString engine;
   GString signature;
   HashStat stats;
+
   public HashEntry() {
+
   }
 
   /**
index 1b248686ea73fcc4a3a3c0a1bb5178e81f4142fe..7c4856206139fa40d190043e370a40280c4c3683 100644 (file)
@@ -299,14 +299,47 @@ public class SpamFilter extends Thread {
       myhe.setengine(engine);
       myhe.setsig(signature);
 
+
+
       // ----- now connect to global data structure and update stats -----
-      HashEntry tmphe = (HashEntry)(mydhmap.getKey(myhe));
+      //HashEntry tmphe = (HashEntry)(mydhmap.getKey(myhe));
+      HashEntry tmphe;
+      FilterStatistic fs;
+      int hashCode = myhe.hashCode();
+      int index1 = mydhmap.hash1(hashCode, mydhmap.table.length);
+      DistributedHashEntry testhe = mydhmap.table[index1];
+      if(testhe==null) {
+        tmphe=null;
+        fs=null;
+      } else {
+        DHashEntry ptr=testhe.array;
+        int point=0;
+        while(ptr !=null) {
+          if(ptr.hashval==hashcode&&ptr.key.equals(key)) {
+            tmphe=ptr.key;
+            fs=ptr.value;
+            point=1;
+            break;
+          }
+          ptr=ptr.next;
+        }
+        if(point != 1) {
+          tmphe=null;
+          fs=null;
+        }
+      }
+      //tmphe has the key at the end
+      //fs has the value at the end      
+
+
       if(tmphe.stats.userid[id] != 1) {
         tmphe.stats.setuserid(id);
       }
 
+
       //---- get value from distributed hash and update spam count
-      FilterStatistic fs = (FilterStatistic) (mydhmap.get(myhe)); 
+      //FilterStatistic fs = (FilterStatistic) (mydhmap.get(myhe)); 
+
 
       //System.out.println(fs.toString());