/// <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]); }
/// <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; }