public class DistributedHashMap {
- DistributedHashEntry[] table;
- float loadFactor;
+ public DistributedHashEntry[] table;
+ public float loadFactor;
public DistributedHashMap(int initialCapacity, float loadFactor) {
init(initialCapacity, loadFactor);
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)) {
if (dhe==null)
return null;
- DHashEntry ptr=dhe.array;
+ HashEntry ptr=dhe.array;
while(ptr!=null) {
if (ptr.hashval==hashcode
if (dhe==null)
return null;
- DHashEntry ptr=dhe.array;
+ HashEntry ptr=dhe.array;
while(ptr!=null) {
if (ptr.hashval==hashcode
if (dhe==null)
return false;
- DHashEntry ptr=dhe.array;
+ HashEntry ptr=dhe.array;
while(ptr!=null) {
if (ptr.hashval==hashcode
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)) {
ptr=ptr.next;
}
- DHashEntry he=global new DHashEntry();
+ HashEntry he=global new HashEntry();
he.value=value;
he.key=key;
he.hashval=hashcode;
return null;
}
+ */
}
class DistributedHashEntry {
class DHashEntry {
- public DHashEntry() {
+ public HashEntry() {
}
int hashval;
- Object key;
- Object value;
+ HashEntry key;
+ FilterStatistic value;
DHashEntry next;
}
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());