public bool Equals(PartitionedBloomFilter other)
        {
            if (this.M != other.M)
            {
                return(false);
            }
            if (this.k != other.k)
            {
                return(false);
            }
            if (this.S != other.S)
            {
                return(false);
            }
            if (this.Hash != other.Hash)
            {
                return(false);
            }
            if (!this.Partitions.SequenceEqual(other.Partitions))
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Adds a new Bloom filter with a restricted false-positive rate to the
        /// Scalable Bloom Filter
        /// </summary>
        internal void AddFilter()
        {
            var fpRate = this.Fp * Math.Pow(this.R, this.Filters.Count);
            var p      = new PartitionedBloomFilter(this.Hint, fpRate);

            if (this.Filters.Any())
            {
                p.SetHash(this.Filters[0].Hash);
            }
            this.Filters.Add(p);
        }
        public void Serialize(Stream stream, PartitionedBloomFilter filter)
        {
            using (var bw = new BinaryWriter(stream))
            {
                bw.Write(DataFormatMajorVersion);
                bw.Write(DataFormatMinorVersion);

                PartitionedBloomState data = filter.GetState();

                Serialize(bw, data);

                bw.Flush();
            }
        }