Dish-0.0.0.5: Hash modules (currently Murmur3)

Safe HaskellNone

Data.Dish.Murmur3

Contents

Description

This is a Haskell wrapper around the C port of MurmurHash3. https://github.com/zcourts/murmur3 MurmurHash3 is available at https://code.google.com/p/smhasher/wiki/MurmurHash3 The hash functions are designed to work efficiently on x86 processors; in particular, they make some assumptions about the endianness of the processor, and about the speed of unaligned reads.

Synopsis

Murmur3 Hash Version

data MHV Source

Constructors

X86_32 
X86_128 
X64_128 

Hashable

class Murmur3Hashable a whereSource

Provides an interface for any value which is capable of being represented as a CString

newtype Str Source

Because String isn't a 'real' type :(

Constructors

Str 

Fields

strCon :: String
 

Instances

Default/Direct Map

Simple, verbose interface for generating hashes

murmur3Source

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> MHV

Which Murmur Hash version to use X86_32, X86_128 or X64_128

-> [Int]

returns 4, 32 bit ints, if X86_32 is used only the first has a value and the other 3 are 0

Base function, which allows you to choose which MHV to use

murmur3'Source

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> MHV

Which Murmur Hash version to use X86_32, X86_128 or X64_128

-> IO [Int]

returns 4, 32 bit ints, if X86_32 is used only the first has a value and the other 3 are 0

X86 32 bits

Generate 32 bit hash values

murmur3IntSource

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> Int

32 bit number generated from the hashable

has the lowest throughput, but also the lowest latency. If you're making a hash table that usually has small keys, this is probably the one you want to use on 32-bit machines. It has a 32-bit output.

murmur3Int'Source

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> IO Int

32 bit number generated from the hashable

X86 128 bits

Generate 128 bit hash values, optimized for 32 bit systems

murmur3IntegerX86Source

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> Integer

128 bit number generated from the hashable

Generate a 128 bit hash from the given value, this function's implementation is optimized for 32 bit architectures but works on any. Has about 30% higher throughput than murmur3Int. Be warned, though, that its latency for a single 16-byte key is about 86% longer!

murmur3IntegerX86'Source

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> IO Integer

128 bit number generated from the hashable

X64 128 bits

Generate 128 bit hash values, optimized for 64 bit systems

murmur3IntegerX64Source

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> Integer

128 bit number generated from the hashable

Generate a 128 bit hash from the given value, this function's implementation is optimized for x64 architectures but works on any. Its throughput is 250% higher than murmur3IntegerX86, but it has roughly the same latency.

murmur3IntegerX64'Source

Arguments

:: Murmur3Hashable a 
=> a

The hashable to be hashed

-> Int

A seed value for the hash function

-> IO Integer

128 bit number generated from the hashable

FFI

murmur3Raw :: Murmur3Hashable a => a -> Int -> MHV -> IO [CUInt]Source

all murmur functions use this and manipulate its response to return a different format