From: "Mauricio Fernández" Date: 2002-08-28T20:02:27+09:00 Subject: Re: ANN: RJudy-0.1 - Judy Arrays for Ruby --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Aug 28, 2002 at 11:25:10AM +0900, Mauricio Fern�ndez wrote: > On Tue, Aug 27, 2002 at 02:41:19PM +0900, Lyle Johnson wrote: > > All, > > > > I've just uploaded RJudy, an extension module that provides a Ruby > > interface to the Judy arrays library. This extension exposes four new > > classes to Ruby (Judy1, JudyL, JudySL and JudyHash). The first three are > > more-or-less direct wrappers of the current Judy API. The last is a > > first cut at a more general replacement for Ruby's Hash (i.e. with > > arbitrary-type keys), based on the approach described in the Judy > > application note "Scalable Hashing". [...] > I've replicated most of your code for the last several hours to use > JudyL inside the internal hash (st_*). > This way, all of Ruby could potentially be faster (including method > lookups and of course builtin hashes). > > I'm attaching a diff, please be indulgent: it's about 4:30AM in my locale > and I'm really in need of some sleep. Got no time to find a place to > upload all this, plus it's small... > > Please take a look at the small attached patch... > I've had it build in 1.7.2 and I have had it running for some time, > seemingly OK, but I'm too tired now to do unit testing :-) I later found some bugs in my plug-in replacement for Hash. I have another patch which apparently fixes everything. It passes the same tests JudyHash does and some others, as st_* is used for everything and Ruby seems to run fine now. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Ok, I'm just uploading the new version of the kernel, v1.3.33, also known as "the buggiest kernel ever". -- Linus Torvalds --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ruby-judy-0.0.1-0.0.1a.patch" --- ruby-judy/st.c Wed Aug 28 03:38:02 2002 +++ ruby-judy2/st.c Wed Aug 28 12:31:23 2002 @@ -293,7 +293,7 @@ Index = 0; PValue = JudyLFirst(old_table->PJLArray[i], &Index, PJE0); while( PValue ) { - if ( *PValue ) { + //FIXME: should assert( *PValue ); ? entry = (st_table_entry **) JudyLIns(&new_table->PJLArray[i], Index, PJE0 ); *entry = alloc(st_table_entry); (*entry)->key = HASHNODE(PValue)->key; @@ -302,12 +302,11 @@ for (oldptr = HASHNODE(PValue)->next; oldptr; oldptr = oldptr->next) { ptr = alloc(st_table_entry); // FIXME: check error in memory allocation - ptr->key = ptr->key; - ptr->record = ptr->record; + ptr->key = oldptr->key; + ptr->record = oldptr->record; ptr->next = *entry; *entry = ptr; } - } PValue = JudyLNext(old_table->PJLArray[i], &Index, PJE0); } } @@ -324,7 +323,7 @@ st_table_entry *tmp; register st_table_entry **ptr, *ptr2; - hash_val = do_hash_bin(*key, table); + hash_val = do_hash(*key, table); ptr = (st_table_entry **) JudyLGet(HASHARRAY(table, hash_val), HASHINDEX(hash_val), PJE0); if (ptr == 0) { @@ -338,7 +337,7 @@ if(tmp) tmp->next = ptr2->next; else // head of the list - *ptr = ptr2->next; + *ptr = (*ptr)->next; free( ptr2 ); if ( ! *ptr ) JudyLDel(&HASHARRAY(table,hash_val), HASHINDEX(hash_val), PJE0); @@ -361,7 +360,7 @@ register st_table_entry *ptr; PPvoid_t pValue; - hash_val = do_hash_bin(*key, table); + hash_val = do_hash(*key, table); pValue = JudyLGet(HASHARRAY(table,hash_val), HASHINDEX(hash_val), PJE0); if (pValue == 0) { @@ -399,7 +398,7 @@ int num_entries = table->num_entries; st_foreach(table, delete_never, never); - table->num_entries = num_entries; + //table->num_entries = num_entries; } void --mP3DRpeJDSE+ciuQ--