From 4601b15b0a4b3922dbe95cc88edca608274cf550 Mon Sep 17 00:00:00 2001 From: adash Date: Tue, 17 Nov 2009 03:45:37 +0000 Subject: [PATCH] revert to old files --- .../SpamFilter/DistributedHashMap.java | 24 +++-- .../Distributed/SpamFilter/SpamFilter.java | 99 +++++++------------ 2 files changed, 45 insertions(+), 78 deletions(-) diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java b/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java index b018bfc5..8ea2010a 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java @@ -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; } diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java b/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java index 7c485620..fbb9b8d4 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java @@ -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 } -- 2.34.1