/// <summary> /// The constructor for deserialization. /// </summary> public HyperLogLogCore(SerializationInfo info, StreamingContext context) { _b = info.GetByte("b"); _m = 1 << _b; _alpha = HyperLogLogInternals.CalculateConstantAlphaCorrectionFactor(_b); _registers = (byte[])info.GetValue("registers", typeof(byte[])); }
/// <summary> /// Creates HyperLogLogCore instance. /// </summary> /// <param name="b"> /// Number of bits of hash used to calculate register index. /// There will be 2^b registers. /// The bigger the value of b the better accuraccy of count will be achieved. /// On the other hand, the greater the value of b, more memory will be used for the registers. /// </param> public HyperLogLogCore(byte b) { if (b < 4 || b > 16) { throw new ArgumentOutOfRangeException(nameof(b), "Parameter 'b' must have value between 4 inclusive and 16 inclusive"); } _b = b; _m = 1 << _b; _registers = new byte[_m]; _alpha = HyperLogLogInternals.CalculateConstantAlphaCorrectionFactor(_b); }