revert to old files
authoradash <adash>
Tue, 17 Nov 2009 03:45:37 +0000 (03:45 +0000)
committeradash <adash>
Tue, 17 Nov 2009 03:45:37 +0000 (03:45 +0000)
Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java
Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java

index b018bfc524a981c022adb4c4042caced38e1c7d5..8ea2010a7089f71c718ccfb147ee9320265769cd 100644 (file)
@@ -1,6 +1,6 @@
 public class DistributedHashMap {
-  public DistributedHashEntry[] table;
-  public float loadFactor;
+  DistributedHashEntry[] table;
+  float loadFactor;
 
   public DistributedHashMap(int initialCapacity, float loadFactor) {
     init(initialCapacity, loadFactor);
@@ -19,14 +19,13 @@ 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;
-    HashEntry ptr=dhe.array;
+    DHashEntry ptr=dhe.array;
 
     if (ptr!=null) {
       if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
@@ -55,7 +54,7 @@ public class DistributedHashMap {
     if (dhe==null)
       return null;
 
-    HashEntry ptr=dhe.array;
+    DHashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode
@@ -76,7 +75,7 @@ public class DistributedHashMap {
     if (dhe==null)
       return null;
 
-    HashEntry ptr=dhe.array;
+    DHashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode
@@ -95,7 +94,7 @@ public class DistributedHashMap {
     if (dhe==null)
       return false;
 
-    HashEntry ptr=dhe.array;
+    DHashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode
@@ -115,7 +114,7 @@ public class DistributedHashMap {
        dhe=global new DistributedHashEntry();
        table[index1]=dhe;
     }
-    HashEntry ptr=dhe.array;
+    DHashEntry ptr=dhe.array;
 
     while(ptr!=null) {
       if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
@@ -126,7 +125,7 @@ public class DistributedHashMap {
       ptr=ptr.next;
     }
 
-    HashEntry he=global new HashEntry();
+    DHashEntry he=global new DHashEntry();
     he.value=value;
     he.key=key;
     he.hashval=hashcode;
@@ -137,7 +136,6 @@ public class DistributedHashMap {
     
     return null;
   }
-  */
 }
 
 class DistributedHashEntry {
@@ -149,10 +147,10 @@ class DistributedHashEntry {
 
 
 class DHashEntry {
-  public HashEntry() {
+  public DHashEntry() {
   }
   int hashval;
-  HashEntry key;
-  FilterStatistic value;
+  Object key;
+  Object value;
   DHashEntry next;
 }
index 7c4856206139fa40d190043e370a40280c4c3683..fbb9b8d4bdae453abf31edc7f4d5f58a311d4367 100644 (file)
@@ -299,75 +299,44 @@ 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;
-      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;
+      if(!mydhmap.containsKey(myhe)) {
+        HashEntry tmphe = (HashEntry)(mydhmap.getKey(myhe));
+        if(tmphe.stats.userid[id] != 1) {
+          tmphe.stats.setuserid(id);
         }
-      }
-      //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)); 
-
-
-      //System.out.println(fs.toString());
-
-      //Allow users to give incorrect feedback
-      int pickemail = myrand.nextInt(100);
-      /* Randomly allow user to provide incorrect feedback */
-      if(pickemail < 95) {
-        //give correct feedback 95% of times
-        //Increment spam or ham value 
-        if(isSpam) {
-          tmphe.stats.incSpamCount(id);
-          fs.increaseSpam();
-        } else {
-          tmphe.stats.incHamCount(id);
-          fs.increaseHam();
-        }
-      } else {
-        // Give incorrect feedback 5% of times
-        if(isSpam) {
-          tmphe.stats.incHamCount(id);
-          fs.increaseHam();
+        //---- get value from distributed hash and update spam count
+        FilterStatistic fs = (FilterStatistic) (mydhmap.get(myhe)); 
+
+        //System.out.println(fs.toString());
+
+        //Allow users to give incorrect feedback
+        int pickemail = myrand.nextInt(100);
+        /* Randomly allow user to provide incorrect feedback */
+        if(pickemail < 95) {
+          //give correct feedback 95% of times
+          //Increment spam or ham value 
+          if(isSpam) {
+            tmphe.stats.incSpamCount(id);
+            fs.increaseSpam();
+          } else {
+            tmphe.stats.incHamCount(id);
+            fs.increaseHam();
+          }
         } else {
-          tmphe.stats.incSpamCount(id);
-          fs.increaseSpam();
-        }
-      } //end of pickemail
-    }
-  }
+          // Give incorrect feedback 5% of times
+          if(isSpam) {
+            tmphe.stats.incHamCount(id);
+            fs.increaseHam();
+          } else {
+            tmphe.stats.incSpamCount(id);
+            fs.increaseSpam();
+          }
+        } //end of pickemail
+      }
+    }//end of for
+  }//end of seedfeedback
 }