Ejemplo n.º 1
0
        private GroupedQueryResults GetSimilaritiesUsingBatchedStrategy(Hashes queryHashes, QueryConfiguration configuration, IModelService modelService)
        {
            var matchedSubFingerprints = modelService.Query(queryHashes, configuration);

            return(queryHashes
                   .AsParallel()
                   .Aggregate(new GroupedQueryResults(queryHashes.DurationInSeconds, queryHashes.RelativeTo), (seed, queryFingerprint) =>
            {
                var matched = matchedSubFingerprints.Where(queryResult => QueryMath.IsCandidatePassingThresholdVotes(queryFingerprint.HashBins, queryResult.Hashes, configuration.ThresholdVotes));
                foreach (var subFingerprint in matched)
                {
                    double score = scoreAlgorithm.GetScore(queryFingerprint, subFingerprint, configuration);
                    seed.Add(queryFingerprint, subFingerprint, score);
                }

                return seed;
            }));
        }