From 296574b8e825da3594047d8d63c9639d90866047 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 22 May 2006 13:28:00 +0000 Subject: [PATCH] Fixed bug #454: Indexing with grs.regx much slower than version 1.3.32. The hash function in the record key management system was improved and the hash size was increased. This make this sub system approx 10 times faster as far as gprof is concerned. There _is_ a bigger overhead with the 64-bit keys over Zebra's 32-bit keys, but not much. --- index/reckeys.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/index/reckeys.c b/index/reckeys.c index 067de6b..bf83a65 100644 --- a/index/reckeys.c +++ b/index/reckeys.c @@ -1,5 +1,5 @@ -/* $Id: reckeys.c,v 1.4 2006-05-10 08:13:22 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: reckeys.c,v 1.5 2006-05-22 13:28:00 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -53,12 +53,15 @@ struct zebra_rec_keys_t_ { struct zebra_rec_key_entry **zebra_rec_keys_mk_hash(zebra_rec_keys_t p, const char *buf, - size_t len) + size_t len, + const struct it_key *key) { unsigned h = 0; size_t i; for (i = 0; ilen; i++) + h = h * 65509 + key->mem[i]; return &p->entries[h % (unsigned) p->hash_size]; } @@ -87,7 +90,7 @@ zebra_rec_keys_t zebra_rec_keys_open() p->decode_handle = iscz1_start(); p->nmem = nmem_create(); - p->hash_size = 127; + p->hash_size = 1023; p->entries = 0; init_hash(p); @@ -148,7 +151,8 @@ int zebra_rec_keys_add_hash(zebra_rec_keys_t keys, const char *str, size_t slen, const struct it_key *key) { - struct zebra_rec_key_entry **kep = zebra_rec_keys_mk_hash(keys, str, slen); + struct zebra_rec_key_entry **kep = zebra_rec_keys_mk_hash(keys, + str, slen, key); while (*kep) { struct zebra_rec_key_entry *e = *kep; -- 1.7.10.4