/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="countConfiguration"></param>
 /// <param name="createFilter"></param>
 protected HybridConfigurationBase(ICountConfiguration <TCount> countConfiguration,
                                   bool createFilter = true) : base(countConfiguration, createFilter)
 {
     //set the custom hash: the hybrid IBF will only use the IdHash (with the pure definition that includes count and hashSum)
     //the reverse IBF will however get the entityHash (and will use a pure definition that only includes the count)
     _entityHash = e => unchecked (BitConverter.ToInt32(_murmurHash.Hash(BitConverter.GetBytes(GetEntityHashImpl(e)), (uint)IdHash(GetId(e))), 0));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="createValueFilter">When <c>true</c> a configuration for the RIBF is created as well.</param>
 protected PairConfigurationBase(ICountConfiguration <TCount> configuration, bool createValueFilter = true) :
     base(configuration, createValueFilter)
 {
     _entityHash = kv => kv.Value == 0 ? 1 : kv.Value;
     //by changing the entity hash, the pure function needs to be redefined (which increases the potential error rate)
     _isPure = (d, p) => CountConfiguration.IsPure(d.Counts[p]);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="createValueFilter"></param>
 protected ReverseConfigurationBase(ICountConfiguration <TCount> configuration, bool createValueFilter = true) :
     base(configuration, createValueFilter)
 {
     //the hashSum value is different.
     _entityHash = e => unchecked (BitConverter.ToInt32(_murmurHash.Hash(BitConverter.GetBytes(GetEntityHashImpl(e)), (uint)IdHash(GetId(e))), 0));
     //with the entity hash no longer equal to the Id hash, the definition of pure has to be modified.
     _isPure = (d, p) => CountConfiguration.IsPure(d.Counts[p]);
 }
示例#4
0
 /// <summary>
 /// The given <paramref name="position"/> is not considered relevant when the count for that position equals the identity.
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="data"></param>
 /// <param name="position"></param>
 /// <returns></returns>
 private static bool IsMember(
     ICountConfiguration <TCount> configuration,
     InvertibleBloomFilterData <TId, THash, TCount> data,
     long position)
 {
     return(configuration
            .Comparer
            .Compare(
                configuration.Identity,
                data.Counts[position]) != 0);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 protected KeyConfigurationBase(ICountConfiguration <TCount> configuration, bool createValueFilter = true) :
     base(createValueFilter)
 {
     _countConfiguration = configuration;
     _getId  = GetIdImpl;
     _idHash = id =>
     {
         var res = BitConverter.ToInt32(_murmurHash.Hash(BitConverter.GetBytes(id)), 0);
         return(res == 0 ? 1 : res);
     };
     _hashes = (hash, hashCount) => ComputeHash(hash, BitConverter.ToInt32(_murmurHash.Hash(BitConverter.GetBytes(hash), 912345678), 0), hashCount, 1);
     //the hashSum value is an identity hash.
     _entityHash = e => IdHash(GetId(e));
     _isPure     = (d, p) => CountConfiguration.IsPure(d.Counts[p]) &&
                   HashEqualityComparer.Equals(d.HashSumProvider[p], IdHash(d.IdSumProvider[p]));
     _idAdd                = _idRemove = (id1, id2) => id1 ^ id2;
     _idIntersect          = (id1, id2) => id1 & id2;
     _hashIdentity         = 0;
     _idIdentity           = 0L;
     _hashAdd              = _hashRemove = (h1, h2) => h1 ^ h2;
     _hashIntersect        = (h1, h2) => h1 & h2;
     _idEqualityComparer   = EqualityComparer <long> .Default;
     _hashEqualityComparer = EqualityComparer <int> .Default;
 }
 public KeyValuePairBloomFilterConfiguration(ICountConfiguration <sbyte> configuration, bool createValueFilter = true) :
     base(configuration, createValueFilter)
 {
 }