示例#1
0
        public void Murmur3FilterCheck()
        {
            BasicFilter filter = new BasicFilter(50, HashFunc.Murmur3);

            foreach (string str in WordList)
            {
                filter.Insert(str);
            }

            foreach (string str in WordList)
            {
                Assert.True(filter.Check(str).Presence == BloomPresence.MightBeInserted);
            }

            // This was brute-forced not to be in the set
            Assert.True(filter.Check("notInThere5").Presence == BloomPresence.NotInserted);
        }
示例#2
0
        public void SHA512FilterCheck()
        {
            BasicFilter filter = new BasicFilter(50, HashFunc.SHA512);

            foreach (string str in WordList)
            {
                filter.Insert(str);
            }

            foreach (string str in WordList)
            {
                Assert.True(filter.Check(str).Presence == BloomPresence.MightBeInserted);
            }

            // This was brute-forced not to be in the set
            Assert.True(filter.Check("notInThere4").Presence == BloomPresence.NotInserted);

            // This was brute-forced to have matching bits although it's not in the set
            Assert.True(filter.Check("notInThere11").Presence == BloomPresence.MightBeInserted);
        }
示例#3
0
 static void FilterCheck(BasicFilter filter, List<string> words)
 {
     var watch = new Stopwatch();
     double p = 0.0;
     foreach (string w in words)
     {
         var res = filter.Check(w);
         p = res.Probability;
     }
     watch.Stop();
     Console.WriteLine($"{filter.HashFunction}, k={filter.HashNumber}, {words.Count} checks: {(double)watch.ElapsedMilliseconds / 1000} sec with p={p}");
 }
示例#4
0
        public void BasicFilterWithPrecalculatedProb()
        {
            BasicFilter filter = new BasicFilter(40000, 1.0E-7);

            foreach (string str in WordList)
            {
                filter.Insert(str);
            }

            foreach (string str in WordList)
            {
                Assert.True(filter.Check(str).Presence == BloomPresence.MightBeInserted);
            }

            // This was brute-forced not to be in the set
            Assert.True(filter.Check("notInThere4").Presence == BloomPresence.NotInserted);

            // This is inside the set
            FilterResult res = filter.Check("radioimmunoelectrophoresis");

            Assert.True(res.Presence == BloomPresence.MightBeInserted);
            Assert.True(res.Probability <= 1.0E-7);
        }