public void AccumulateHammingSimilarity(IEnumerable <SubFingerprintData> candidates, HashedFingerprint expected, ConcurrentDictionary <IModelReference, ResultEntryAccumulator> accumulator)
 {
     foreach (var subFingerprint in candidates)
     {
         byte[]             signature         = hashConverter.ToBytes(subFingerprint.Hashes, expected.SubFingerprint.Length);
         int                hammingSimilarity = CalculateHammingSimilarity(expected.SubFingerprint, signature);
         SubFingerprintData fingerprint       = subFingerprint;
         accumulator.AddOrUpdate(
             subFingerprint.TrackReference,
             reference => new ResultEntryAccumulator(expected, fingerprint, hammingSimilarity),
             (reference, entryAccumulator) => entryAccumulator.Add(expected, fingerprint, hammingSimilarity));
     }
 }
Ejemplo n.º 2
0
 public IList <HashedFingerprint> ReadHashedFingerprintsByTrackReference(IModelReference trackReference)
 {
     return(this.PrepareStoredProcedure(SpReadSubFingerprintsByTrackId)
            .WithParameter("TrackId", trackReference.Id, DbType.Int32)
            .Execute()
            .AsListOfModel <SubFingerprintDTO>()
            .Select(dto =>
     {
         var hashes = GetHashes(dto);
         byte[] signature = hashConverter.ToBytes(hashes, 100);
         return new HashedFingerprint(signature, hashes, dto.SequenceNumber, dto.SequenceAt, string.IsNullOrEmpty(dto.Clusters) ? Enumerable.Empty <string>() : dto.Clusters.Split(','));
     }).ToList());
 }
Ejemplo n.º 3
0
 private HashedFingerprint GetHashedFingerprint(SubFingerprintDTO subFingerprintDto)
 {
     long[] hashBins  = dictionaryToHashConverter.FromSolrDictionaryToHashes(subFingerprintDto.Hashes);
     byte[] signature = hashConverter.ToBytes(hashBins, fingerprintLength);
     return(new HashedFingerprint(signature, hashBins, subFingerprintDto.SequenceNumber, subFingerprintDto.SequenceAt, subFingerprintDto.Clusters));
 }