[rsyslog] help request: hashtable library?

Aaron Wiebe epiphani at gmail.com
Mon Sep 27 15:40:09 CEST 2010

Hash table algorithms are usually very dependent on what you're using
as a key.  What are you planning to use as a key?

If you're looking for something generic, I'm generally a fan of perl's
hashing algorithm:

    if (!len)
        len = strlen(rkey);
    else if (table->flags & HASH_FL_STRING)
        len = strlen(rkey);
        if (len > table->keylen)
            len = table->keylen;
    if (table->flags & HASH_FL_NOCASE)
        while (len--)
            hash = hash * 33 + ToLower(*rkey++);
        while (len--)
            hash = hash * 33 + *rkey++;

    return hash % table->size;

That should be fairly self-explanatory... but feel free to ask
questions.  I pulled that out of Bahamut's src/throttle.c where we use
a generic hashing mechanism for throttling connections.  You may want
to take a look at that code.


On Mon, Sep 27, 2010 at 9:24 AM, Rainer Gerhards
<rgerhards at hq.adiscon.com> wrote:
> Hi all,
> I am about to implement input rate limiting for imuxsock. This will be done
> on a per-pid (or per-cgroup) basis. I now have almost all plumbing done, but
> now need to implement a hash table to lookup the rate limiter objects. Before
> I go ahead and do my own implementation, I wanted to ask if you can recommend
> a small and lightweight hashtable "library".
> Doing some limited search myself, I found
> http://www.cl.cam.ac.uk/~cwc22/hashtable/
> which looks quite usable to me. But I thought I ask if you can recommend some
> other good libs.
> Feedback is appreciated,
> Rainer
> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog
> http://www.rsyslog.com

More information about the rsyslog mailing list