public void HybridIntersectDifferentFiltersTest() { var addSize = 10000; var testData = DataGenerator.Generate().Take(addSize).ToArray(); var errorRate = 0.001F; var size = testData.Length; var configuration = new HybridDefaultBloomFilterConfiguration(); var bloomFilter = new InvertibleHybridBloomFilter <TestEntity, long, sbyte>(configuration); bloomFilter.Initialize(2 * size, errorRate); foreach (var itm in testData) { bloomFilter.Add(itm); } var bloomFilter2 = new InvertibleHybridBloomFilter <TestEntity, long, sbyte>(configuration); bloomFilter2.Initialize(2 * size, errorRate); foreach (var itm in testData.Skip(1000)) { bloomFilter2.Add(itm); } bloomFilter.Intersect(bloomFilter2); Assert.AreEqual(9000, bloomFilter.ItemCount); var count = testData.Skip(1000).Count(bloomFilter.Contains); //Note: intersect introduces a horrible error rate when utilizing XOR, so don't actually use intersect. //There are however definitions of operations possible where the intersect would not have this horrible effect. Assert.IsTrue(count > 6000); Assert.IsTrue(testData.Take(1000).All(d => !bloomFilter.Contains(d))); }
public void HybridIntersectEqualFiltersTest() { var addSize = 10000; var testData = DataGenerator.Generate().Take(addSize).ToArray(); var errorRate = 0.001F; var size = testData.Length; var configuration = new HybridDefaultBloomFilterConfiguration(); var bloomFilter = new InvertibleHybridBloomFilter <TestEntity, long, sbyte>(configuration); bloomFilter.Initialize(2 * size, errorRate); foreach (var itm in testData) { bloomFilter.Add(itm); } var bloomFilter2 = new InvertibleHybridBloomFilter <TestEntity, long, sbyte>(configuration); bloomFilter2.Initialize(2 * size, errorRate); foreach (var itm in testData) { bloomFilter2.Add(itm); } bloomFilter.Intersect(bloomFilter2); Assert.AreEqual(addSize, bloomFilter.ItemCount); Assert.IsTrue(testData.All(bloomFilter.Contains)); }