Ejemplo n.º 1
0
 /// <summary>
 /// Generate the sequence of cell locations to hash the given key to.
 /// </summary>
 /// <param name="configuration">The configuration</param>
 /// <param name="data">The invertible Bloom filter data</param>
 /// <param name="value">The hash value</param>
 /// <returns>A sequence of positions to hash the data to (length equals the number of hash functions configured).</returns>
 internal static IEnumerable <long> Probe <TId, TCount>(
     this IBloomFilterConfiguration <TId, int> configuration,
     IInvertibleBloomFilterData <TId, int, TCount> data,
     int value)
     where TCount : struct
     where TId : struct
 {
     return(configuration
            .Probe(data.BlockSize, data.HashFunctionCount, value));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Generate the sequence of cell locations to hash the given key to.
 /// </summary>
 /// <param name="configuration">The configuration</param>
 /// <param name="data">The invertible Bloom filter data</param>
 /// <param name="value">The hash value</param>
 /// <returns>A sequence of positions to hash the data to (length equals the number of hash functions configured).</returns>
 internal static IEnumerable <long> Probe <TId>(
     this IBloomFilterConfiguration <TId, int> configuration,
     long blockSize,
     uint hashFunctionCount,
     int value)
     where TId : struct
 {
     return(configuration
            .Hashes(value, hashFunctionCount)
            .Select(p => Math.Abs(p % blockSize)));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Compress the estimator data.
        /// </summary>
        /// <param name="estimator"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        internal static IBitMinwiseHashEstimatorFullData Compress <TId, TCount>(
            this IBitMinwiseHashEstimatorFullData estimator,
            IBloomFilterConfiguration <TId, int> configuration)
            where TId : struct
            where TCount : struct
        {
            if (configuration?.FoldingStrategy == null || estimator == null)
            {
                return(null);
            }
            var fold = configuration.FoldingStrategy.FindCompressionFactor(configuration, estimator.Capacity, estimator.Capacity, estimator.ItemCount);

            return(fold.HasValue ? estimator.Fold(fold.Value) : null);
        }