Inheritance: ITrackDao
 public void SetUp()
 {
     var ramStorage = new RAMStorage(NumberOfHashTables);
     HashBinDao = new HashBinDao(ramStorage);
     TrackDao = new TrackDao(ramStorage);
     SubFingerprintDao = new SubFingerprintDao(ramStorage);
 }
Beispiel #2
0
        public IEnumerable <SpectralImageData> GetSpectralImagesByTrackId(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                throw new ArgumentException($"{nameof(trackId)} is not present in the storage");
            }

            return(SpectralImageDao.GetSpectralImagesByTrackReference(track.TrackReference));
        }
Beispiel #3
0
        public void Insert(TrackInfo track, Hashes hashes)
        {
            var fingerprints = hashes.ToList();

            if (!fingerprints.Any())
            {
                return;
            }

            var(trackData, subFingerprints) = modelReferenceTracker.AssignModelReferences(track, hashes);
            TrackDao.InsertTrack(trackData);
            SubFingerprintDao.InsertSubFingerprints(subFingerprints);
        }
Beispiel #4
0
        public void InsertSpectralImages(IEnumerable <float[]> spectralImages, string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                throw new ArgumentException($"{nameof(trackId)} is not present in the storage");
            }

            var images = AssignModelReferences(spectralImages, track);

            SpectralImageDao.InsertSpectralImages(images);
        }
Beispiel #5
0
        public int DeleteTrack(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                return(0);
            }

            var trackReference = track.TrackReference;

            return(SubFingerprintDao.DeleteSubFingerprintsByTrackReference(trackReference) + TrackDao.DeleteTrack(trackReference));
        }
Beispiel #6
0
        public TrackInfo?ReadTrackById(string trackId)
        {
            var trackData = TrackDao.ReadTrackById(trackId);

            if (trackData == null)
            {
                return(null);
            }

            var metaFields = CopyMetaFields(trackData.MetaFields);

            metaFields.Add("TrackLength", $"{trackData.Length: 0.000}");
            return(new TrackInfo(trackData.Id, trackData.Title, trackData.Artist, metaFields, trackData.MediaType));
        }
        /// <inheritdoc cref="IModelService.DeleteTrack"/>
        public void DeleteTrack(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                return;
            }

            var trackReference = track.TrackReference;

            SubFingerprintDao.DeleteSubFingerprintsByTrackReference(trackReference);
            TrackDao.DeleteTrack(trackReference);
        }
Beispiel #8
0
        public AVHashes ReadHashesByTrackId(string trackId)
        {
            var track = TrackDao.ReadTrackById(trackId);

            if (track == null)
            {
                return(AVHashes.Empty);
            }

            var fingerprints = SubFingerprintDao
                               .ReadHashedFingerprintsByTrackReference(track.TrackReference)
                               .Select(ToHashedFingerprint);

            return(new AVHashes(new Hashes(fingerprints, track.Length, MediaType.Audio), Hashes.GetEmpty(MediaType.Video)));
        }
        /// <inheritdoc cref="IModelService.UpdateTrack"/>
        public void UpdateTrack(TrackInfo trackInfo)
        {
            var track = TrackDao.ReadTrackById(trackInfo.Id);

            if (track == null)
            {
                throw new ArgumentException($"Could not find track {trackInfo.Id} to update", nameof(trackInfo.Id));
            }

            if (trackInfo.MediaType != track.MediaType)
            {
                throw new ArgumentException($"Can't update media type from {trackInfo.MediaType} to {track.MediaType}. Delete {track.Id} and reinsert with new media type.");
            }

            var subFingerprints = SubFingerprintDao.ReadHashedFingerprintsByTrackReference(track.TrackReference);
            var hashes          = new Hashes(subFingerprints.Select(subFingerprint => new HashedFingerprint(subFingerprint.Hashes, subFingerprint.SequenceNumber, subFingerprint.SequenceAt, subFingerprint.OriginalPoint)), track.Length, track.MediaType);

            DeleteTrack(trackInfo.Id);
            Insert(trackInfo, hashes);
        }
 public FingerprintDaoTest()
 {
     FingerprintDao = new FingerprintDao();
     TrackDao = new TrackDao();
 }
Beispiel #11
0
 public IEnumerable <TrackData> ReadTracksByReferences(IEnumerable <IModelReference> references)
 {
     return(TrackDao.ReadTracksByReferences(references));
 }
Beispiel #12
0
 public IEnumerable <string> GetTrackIds()
 {
     return(TrackDao.GetTrackIds());
 }