hashtables: Mutable hash tables in the ST monad
This package provides a couple of different implementations of mutable hash tables in the ST monad, as well as a typeclass abstracting their common operations, and a set of wrappers to use the hash tables in the IO monad.
QUICK START: documentation for the hash table operations is provided in the Data.HashTable.Class module, and the IO wrappers (which most users will probably prefer) are located in the Data.HashTable.IO module.
This package currently contains three hash table implementations:
Data.HashTable.ST.Cuckoo contains an implementation of "cuckoo hashing" as introduced by Pagh and Rodler in 2001 (see http://en.wikipedia.org/wiki/Cuckoo_hashing). Cuckoo hashing has worst-case O(1) lookups and can reach a high "load factor", in which the table can perform acceptably well even when approaching 90% full. Randomized testing shows this implementation of cuckoo hashing to be slightly faster on insert and slightly slower on lookup than Data.Hashtable.ST.Basic, while being more space efficient by about a half-word per key-value mapping. Cuckoo hashing, like the basic hash table implementation using linear probing, can suffer from long delays when the table is resized.
Data.HashTable.ST.Basic contains a basic open-addressing hash table using linear probing as the collision strategy. On a pure speed basis it should currently be the fastest available Haskell hash table implementation for lookups, although it has a higher memory overhead than the other tables and can suffer from long delays when the table is resized because all of the elements in the table need to be rehashed.
Data.HashTable.ST.Linear contains a linear hash table (see http://en.wikipedia.org/wiki/Linear_hashing), which trades some insert and lookup performance for higher space efficiency and much shorter delays when expanding the table. In most cases, benchmarks show this table to be currently slightly faster than
Data.HashTablefrom the Haskell base library.
It is recommended to create a concrete type alias in your code when using this package, i.e.:
import qualified Data.HashTable.IO as H type HashTable k v = H.BasicHashTable k v foo :: IO (HashTable Int Int) foo = do ht <- H.new H.insert ht 1 1 return ht
Firstly, this makes it easy to switch to a different hash table implementation, and secondly, using a concrete type rather than leaving your functions abstract in the HashTable class should allow GHC to optimize away the typeclass dictionaries.
This package accepts a couple of different cabal flags:
unsafe-tricks, default ON. If this flag is enabled, we use some unsafe GHC-specific tricks to save indirections (namely
reallyUnsafePtrEquality#. These techniques rely on assumptions about the behaviour of the GHC runtime system and, although they've been tested and should be safe under normal conditions, are slightly dangerous. Caveat emptor. In particular, these techniques are incompatible with HPC code coverage reports.
sse42, default OFF. If this flag is enabled, we use some SSE 4.2 instructions (see http://en.wikipedia.org/wiki/SSE4, first available on Intel Core 2 processors) to speed up cache-line searches for cuckoo hashing.
bounds-checking, default OFF. If this flag is enabled, array accesses are bounds-checked.
debug, default OFF. If turned on, we'll rudely spew debug output to stdout.
portable, default OFF. If this flag is enabled, we use only pure Haskell code and try not to use unportable GHC extensions. Turning this flag on forces
Please send bug reports to https://github.com/gregorycollins/hashtables/issues.
[Skip to Readme]
turn on unsafe GHC tricks
if on, use bounds-checking array accesses
if on, spew debugging output to stdout
if on, use SSE 4.2 extensions to search cache lines very efficiently. The portable flag forces this off.
if on, use only pure Haskell code and no GHC extensions.
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
- hashtables-188.8.131.52.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
|Versions [RSS]||184.108.40.206, 220.127.116.11, 18.104.22.168, 22.214.171.124, 126.96.36.199, 188.8.131.52, 184.108.40.206, 220.127.116.11, 18.104.22.168, 22.214.171.124, 126.96.36.199, 188.8.131.52, 184.108.40.206, 220.127.116.11, 18.104.22.168, 22.214.171.124, 126.96.36.199, 188.8.131.52, 184.108.40.206, 220.127.116.11, 18.104.22.168, 22.214.171.124, 126.96.36.199, 188.8.131.52, 184.108.40.206, 220.127.116.11, 18.104.22.168, 22.214.171.124, 126.96.36.199, 188.8.131.52, 1.3|
|Dependencies||base (>=4 && <5), ghc-prim, hashable (>=1.1 && <1.2 || >=1.2.1 && <1.3), primitive (<0.7), vector (>=0.7 && <0.12) [details]|
|Copyright||(c) 2011-2014, Google, Inc.|
|Revised||Revision 1 made by CarterSchonwald at 2019-05-17T18:04:36Z|
|Uploaded||by GregoryCollins at 2015-11-20T00:09:39Z|
|Distributions||Arch:184.108.40.206, Debian:220.127.116.11, Fedora:18.104.22.168, FreeBSD:22.214.171.124, LTSHaskell:126.96.36.199, NixOS:188.8.131.52, Stackage:1.3, openSUSE:184.108.40.206|
|Downloads||93538 total (434 in the last 30 days)|
|Rating||2.5 (votes: 4) [estimated by Bayesian average]|
|Status||Docs uploaded by user [build log]
All reported builds failed as of 2015-11-20 [all 2 reports]