예제 #1
0
        public static HyperLogLog Merge(params HyperLogLog[] hlls)
        {
            if (hlls == null || hlls.Length == 0)
            {
                return(new HyperLogLog());
            }

            var b = hlls[0].B;

            if (hlls.Any(hyperLogLog => b != hyperLogLog.B))
            {
                throw new ArgumentException("All HyperLogLogs needs to be on the same size", "hlls");
            }


            var result = new HyperLogLog(hlls[0]._hashAlgorithm, hlls[0]._bytesConverter, hlls[0].B);

            for (int i = 0; i < result.M; i++)
            {
                result._registers[i] = hlls.Max(x => x._registers[i]);
            }

            return(result);
        }
예제 #2
0
        public static HyperLogLog Merge(params HyperLogLog[] hlls)
        {
            if (hlls == null || hlls.Length == 0)
                return new HyperLogLog();

            var b = hlls[0].B;

            if (hlls.Any(hyperLogLog => b != hyperLogLog.B))
                throw new ArgumentException("All HyperLogLogs needs to be on the same size", "hlls");


            var result = new HyperLogLog(hlls[0]._hashAlgorithm, hlls[0]._bytesConverter, hlls[0].B);

            for (int i = 0; i < result.M; i++)
            {
                result._registers[i] = hlls.Max(x => x._registers[i]);
            }

            return result;
        }