Harmon Nine wrote:
The addition of the htAddOverWrite function to the devel version would
be great.  In fact, I've got a diff file with a few other changes you
may want to include.  In particular, it changes the calls to "htAdd" in
the reflect module to "htAddOverWrite".  It also has a typedef change
that allows the reflect, fcp, etc. modules to build in the Debian
distribution with "dpkg-buildpackage" (i.e. ucontext_t typedef is
changed to ucontext_mozart_t to avoid a conflict with the file
/usr/include/sys/ucontext.h)

I just had a quick look at reflect_space.hh. The comment before TableClass suggests that you need a "destructive" insertion in the hash table...

Here is a diff file for extending AddressHashTable with a method htAddOverWrite. I made this diff against the cvs trunk of Mozart. I suggest you apply it to your own copy of Mozart, and give it a try.

If this allows you to fix the reflect module, then send me back a diff with all the changes. Send me also something to reproduce the bug. I can double-check the bug and the fix, and commit it to the cvs.

Cheers,
raph

Index: platform/emulator/hashtbl.cc
===================================================================
RCS file: /services/mozart/CVS/mozart/platform/emulator/hashtbl.cc,v
retrieving revision 1.38
diff -r1.38 hashtbl.cc
448a449,492
> // variant of htAdd(), overwrites an existing entry with the same key
> void AddressHashTable::htAddOverWrite(void *k, void *val)
> {
>   if (counter > percent) resize();
> 
>   //
>   Assert(k != htEmpty);
>   Assert(val != htEmpty);
>   unsigned int m = ((unsigned int) k) * ((unsigned int) 0x9e6d5541);
>   unsigned int pkey = m >> rsBits;
>   Assert(pkey == primeHashFunc(k));
>   unsigned int ikey = 0;
>   int key = (int) pkey;
>   DebugCode(int step = 1;);
> 
>   //
>   while (1) {
>     if (table[key].isEmpty()) {
>       // certainly not there;
>       table[key].setKey(k);
>       table[key].setValue(val);
>       counter++;
>       break;
>     } else if (table[key].getKey() == k) {
>       // already there;
>       table[key].setValue(val);
>       break;
>     } else {
>       // next hop:
>       if (ikey == 0) {
>       ikey = ((m << slsBits) >> rsBits) | 0x1;
>       Assert(ikey == incHashFunc(k));
>       Assert(ikey < tableSize);
>       }
>       key -= ikey;
>       if (key < 0)
>       key += tableSize;
>       DebugCode(step++;);
>     }
>   }
>   DebugCode(nsearch++;);
>   DebugCode(tries += step);
> }
> 
Index: platform/emulator/hashtbl.hh
===================================================================
RCS file: /services/mozart/CVS/mozart/platform/emulator/hashtbl.hh,v
retrieving revision 1.27
diff -r1.27 hashtbl.hh
188a189
>   void htAddOverWrite(void *k, void *val);
_________________________________________________________________________________
mozart-hackers mailing list                           
[email protected]      
http://www.mozart-oz.org/mailman/listinfo/mozart-hackers

Reply via email to