Bloom filter + MurmurHash

Source: Internet
Author: User

is a hash method, in fact, the core idea is that a string through a number of ordinary hash function mapping to the hash table, and then the same time to retrieve the hash function, if all the hash table appears, then there is a great possibility of the occurrence, If it does not appear then certainly did not appear.

You can use the formula to calculate how many ordinary hash functions and how much mapping space to make the correct rate to the lowest.

There is a known as the universal hash function, looked at the next introduction looks very dick, so record down.

//-----------------------------------------------------------------------------//MurmurHash2, 64-bit versions, by Austin Appleby//The same caveats as 32-bit MurmurHash2 apply Here-beware of alignment//and endian-ness issues if used across multiple platforms.typedef unsignedLong intuint64_t;//64-bit Hash for 64-bit platformsuint64_t murmurhash64a (Const void* Key,intLen, unsignedintseed) {        Constuint64_t m =0xc6a4a7935bd1e995; Const intR = -; uint64_t h= Seed ^ (Len *m); Constuint64_t * data = (Constuint64_t *) key; Constuint64_t * end = data + (len/8);  while(Data! =end) {uint64_t k= *data++; K*=m; K^= k >>R; K*=m; H^=K; H*=m; }        ConstUnsignedChar* Data2 = (ConstUnsignedChar*) data; Switch(Len &7)        {         Case 7: H ^= uint64_t (data2[6]) << -;  Case 6: H ^= uint64_t (data2[5]) << +;  Case 5: H ^= uint64_t (data2[4]) << +;  Case 4: H ^= uint64_t (data2[3]) << -;  Case 3: H ^= uint64_t (data2[2]) << -;  Case 2: H ^= uint64_t (data2[1]) <<8;  Case 1: H ^= uint64_t (data2[0]); H*=m;         }; H^= h >>R; H*=m; H^= h >>R; returnh;} //64-bit Hash for 32-bit platformsuint64_t murmurhash64b (Const void* Key,intLen, unsignedintseed) {        ConstUnsignedintm =0x5bd1e995; Const intR = -; unsignedintH1 = seed ^Len; unsignedintH2 =0; ConstUnsignedint* Data = (ConstUnsignedint*) key;  while(Len >=8) {unsignedintK1 = *data++; K1*= m; K1 ^= K1 >> R; K1 *=m; H1*= m; H1 ^=K1; Len-=4; unsignedintK2 = *data++; K2*= m; K2 ^= K2 >> R; K2 *=m; H2*= m; H2 ^=K2; Len-=4; }        if(Len >=4) {unsignedintK1 = *data++; K1*= m; K1 ^= K1 >> R; K1 *=m; H1*= m; H1 ^=K1; Len-=4; }        Switch(len) { Case 3: H2 ^= (unsignedChar*) data) [2] << -;  Case 2: H2 ^= (unsignedChar*) data) [1] <<8;  Case 1: H2 ^= (unsignedChar*) data) [0]; H2*=m;        }; H1^= H2 >> -; H1 *=m; H2^= H1 >> A; H2 *=m; H1^= H2 >> -; H1 *=m; H2^= H1 >> +; H2 *=m; uint64_t h=H1; H= (h << +) |H2; returnh;} 

Bloom filter + MurmurHash

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.