1 = Brief overview of hash functions supported by Ruby TDB
3 Ruby TDB supports several alternative hash functions in addition to the
4 defaults supported by TDB upstream. Hash functions behave and perform
5 differently depending on the key and type of keys you use. We support
6 several popular hash functions (and will accept patches to support
9 Changing hash functions on an already-created database will cause
10 corruption, so don't do it.
12 == TDB Upstream Defaults
14 * the default hash use by TDB is based on the hash algorithm from gdbm.
15 You may specify this by passing explicitly to TDB.new:
16 <code>:hash => :default</code>
18 * the new default (available via TDB::INCOMPATIBLE_HASH) is the Jenkins
19 {lookup3 hash}[http://www.burtleburtle.net/bob/c/lookup3.c].
20 <code>:hash => :jenkins_lookup3</code>
24 The {Murmur}[https://sites.google.com/site/murmurhash/] family of hashes
25 are supported by Ruby TDB. Most of these are not endian-neutral so
26 databases are no compatible between machines of different endianness and
27 were designed with x86 and x86_64 in mind (they may crash or not work on
30 * :murmur3a - The latest 32-bit version optimized for x86
31 https://code.google.com/p/smhasher/wiki/MurmurHash3
33 * :murmur2 - the simple and fast implementation
35 * :murmur2a - words of the author:
37 This is a variant of MurmurHash2 modified to use the
38 Merkle-Damgard construction. Bulk speed should be identical to
39 Murmur2, small-key speed will be 10%-20% slower due to the added
40 overhead at the end of the hash.
42 This variant fixes a minor issue where null keys were more likely to
43 collide with each other than expected, and also makes the algorithm
44 more amenable to incremental implementations. All other caveats from
45 MurmurHash2 still apply.
47 * :murmur2_aligned - a safer, but slower variant of :murmur2 designed
48 for platforms where unaligned 4-byte reads can crash the machine.
50 * :murmur2_neutral - endian/alignment-neutral version of the simple
51 implementation, half as fast according to the author.
53 * :murmur1 - simple and fast historical version
55 * :murmur1_aligned - according to the author, the performance of this
56 one should be as good or better than the simple version.
60 * :fnv1a - the recommended variant of the popular
61 {Fowler-Noll-Vo}[http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash_function]
66 * :djb3 - The hash currently favored by Bernstein.
67 See http://www.cse.yorku.ca/~oz/hash.html
69 * :djb2 - See http://www.cse.yorku.ca/~oz/hash.html