コード例 #1
0
        public int DeleteTrack(IModelReference trackReference)
        {
            int subIds = this.DeleteSubFingerprintsForTrack(trackReference);

            this.solrForTracksCore.Delete(SolrModelReference.GetId(trackReference));
            this.solrForTracksCore.Commit();
            return(1 + subIds);
        }
コード例 #2
0
        public TrackData ReadTrack(IModelReference trackReference)
        {
            var trackId = SolrModelReference.GetId(trackReference);
            var query   = new SolrQuery(string.Format("trackId:{0}", trackId));

            var results = this.solrForTracksCore.Query(query);

            return(FirstFromResultSet(results));
        }
コード例 #3
0
        private int DeleteSubFingerprintsForTrack(IModelReference trackReference)
        {
            string trackId = SolrModelReference.GetId(trackReference);
            string readAll = string.Format("trackId:{0}", trackId);
            var    results = solrForSubfingerprintsCore.Query(new SolrQuery(readAll));
            var    ids     = results.Select(dto => dto.SubFingerprintId).ToList();

            solrForSubfingerprintsCore.Delete(ids);
            solrForSubfingerprintsCore.Commit();
            return(ids.Count);
        }
コード例 #4
0
 private SubFingerprintDTO GetSubFingerprintDto(IModelReference trackReference, HashedFingerprint hash)
 {
     return(new SubFingerprintDTO
     {
         SubFingerprintId = Guid.NewGuid().ToString(),
         Hashes = dictionaryToHashConverter.FromHashesToSolrDictionary(hash.HashBins),
         SequenceAt = hash.StartsAt,
         SequenceNumber = hash.SequenceNumber,
         TrackId = SolrModelReference.GetId(trackReference),
         Clusters = hash.Clusters
     });
 }
コード例 #5
0
        public IModelReference InsertTrack(TrackData track)
        {
            Guid id  = Guid.NewGuid();
            var  dto = new TrackDTO
            {
                Id             = id.ToString(),
                Album          = track.Album,
                Artist         = track.Artist,
                ISRC           = track.ISRC,
                ReleaseYear    = track.ReleaseYear,
                Title          = track.Title,
                TrackLengthSec = track.Length
            };

            this.solrForTracksCore.Add(dto);
            this.solrForTracksCore.Commit();
            var trackReference = new SolrModelReference(id.ToString());

            track.TrackReference = trackReference;
            return(trackReference);
        }
コード例 #6
0
        public IList <HashedFingerprint> ReadHashedFingerprintsByTrackReference(IModelReference trackReference)
        {
            var results = solr.Query(string.Format("trackId:{0}", SolrModelReference.GetId(trackReference)));

            return(results.Select(GetHashedFingerprint).ToList());
        }