Class: Fairy::HValueGenerator::MurMur
- Inherits:
-
Object
- Object
- Fairy::HValueGenerator::MurMur
- Defined in:
- lib/fairy/share/hash-murmur.rb
Overview
mhash is modiftied from MurmerHash(murmurhash.googlepages.com/).
Constant Summary collapse
- FIX_MASK =
0x3fff_ffff
- MASK24 =
0xffff_ffff_ffff
- MAGIC =
0x7fd652ad & FIX_MASK
- R =
18
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(h) ⇒ MurMur
constructor
A new instance of MurMur.
- #str_hash(data) ⇒ Object
- #value(data) ⇒ Object
Constructor Details
Class Method Details
Instance Method Details
#str_hash(data) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fairy/share/hash-murmur.rb', line 32 def str_hash(data) h = @seed for k in (data+@postfix).unpack("N*") k *= MAGIC k ^= k >> R k &= FIX_MASK k *= MAGIC k &= FIX_MASK h = @seed * MAGIC k &= FIX_MASK h ^= k end h ^= h >> 13 h *= MAGIC h &= FIX_MASK h ^= h >> 15 h end |