public BloomFilter(int size = 1024, int hashCount = 8)
        {
            if (size < 1)
            {
                throw new ArgumentException("You must have at least 1 item in the filter");
            }

            if (hashCount < 1)
            {
                throw new ArgumentException("You must have at least 1 hash");
            }

            Bits = new bool[size];

            var rand = new Random();

            Hashes = Enumerable
                     .Repeat(int.MaxValue, hashCount)
                     .Select(max => rand.Next(0, max))
                     .Select(seed => {
                Func <byte[], uint> func = bytes => MurmurHash3.Hash32(bytes, (uint)seed);
                return(func);
            })
                     .ToArray();
        }
Esempio n. 2
0
        private static uint GetMurmurHashValue(string word)
        {
            const uint seed        = 9;
            var        encodedWord = Encoding.ASCII.GetBytes(word);
            uint       hashResult  = MurmurHash3.Hash32(encodedWord, seed);

            return(hashResult);
        }