diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-10-24 10:33:08 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-10-24 10:33:08 +0800 |
commit | 04780422995146b73e64c37ad79f42516c77d52e (patch) | |
tree | 12663cb6be8533f50e7820563f1b705f2c5f6231 /libibex/hash.c | |
parent | bdb308067c223640c2c14ebd92205e0ae1d20326 (diff) | |
download | gsoc2013-evolution-04780422995146b73e64c37ad79f42516c77d52e.tar.gz gsoc2013-evolution-04780422995146b73e64c37ad79f42516c77d52e.tar.zst gsoc2013-evolution-04780422995146b73e64c37ad79f42516c77d52e.zip |
Dumps the contents of indexs.
2000-10-24 Not Zed <NotZed@HelixCode.com>
* dumpindex.c: Dumps the contents of indexs.
* hash.c (ibex_hash_dump_rec): Also print the word count.
* wordindex.c (unindex_name): Cross-check the cache as well.
svn path=/trunk/; revision=6139
Diffstat (limited to 'libibex/hash.c')
-rw-r--r-- | libibex/hash.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libibex/hash.c b/libibex/hash.c index 25a6e92ef9..9395e1e00b 100644 --- a/libibex/hash.c +++ b/libibex/hash.c @@ -622,9 +622,20 @@ hash_insert(struct _IBEXIndex *index, const char *key, int keylen) /* debug */ void ibex_hash_dump(struct _IBEXIndex *index); +static void ibex_hash_dump_rec(struct _IBEXIndex *index, int *words, int *wordslen); -void -ibex_hash_dump(struct _IBEXIndex *index) +void ibex_hash_dump(struct _IBEXIndex *index) +{ + int words = 0, wordslen=0; + + ibex_hash_dump_rec(index, &words, &wordslen); + + printf("Total words = %d, bytes = %d, ave length = %f\n", words, wordslen, (double)wordslen/(double)words); +} + + +static void +ibex_hash_dump_rec(struct _IBEXIndex *index, int *words, int *wordslen) { int i; struct _hashtableblock *table; @@ -643,6 +654,8 @@ ibex_hash_dump(struct _IBEXIndex *index) while (hashbucket) { int len; + *words = *words + 1; + bucket = (struct _hashblock *)ibex_block_read(index->blocks, HASH_BLOCK(hashbucket)); printf(" bucket %d: [used %d]", hashbucket, bucket->used); if (HASH_INDEX(hashbucket) == 0) { @@ -655,6 +668,9 @@ ibex_hash_dump(struct _IBEXIndex *index) printf("'%.*s' = %d next=%d\n", len, &bucket->hb_keydata[bucket->hb_keys[HASH_INDEX(hashbucket)].keyoffset], bucket->hb_keys[HASH_INDEX(hashbucket)].root, bucket->hb_keys[HASH_INDEX(hashbucket)].next); + + *wordslen = *wordslen + len; + ibex_diskarray_dump(index->blocks, bucket->hb_keys[HASH_INDEX(hashbucket)].root << BLOCK_BITS, bucket->hb_keys[HASH_INDEX(hashbucket)].tail); |