Inheritance: ISubFingerprintDao
Ejemplo n.º 1
0
 public void SetUp()
 {
     var ramStorage = new RAMStorage(NumberOfHashTables);
     HashBinDao = new HashBinDao(ramStorage);
     TrackDao = new TrackDao(ramStorage);
     SubFingerprintDao = new SubFingerprintDao(ramStorage);
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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));
        }
        /// <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);
        }
Ejemplo n.º 5
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 void SetUp()
 {
     var ramStorage = new RAMStorage(NumberOfFingerprints);
     SubFingerprintDao = new SubFingerprintDao(ramStorage);
     TrackDao = new TrackDao(ramStorage);
 }
Ejemplo n.º 8
0
        public IEnumerable <SubFingerprintData> Query(Hashes hashes, QueryConfiguration config)
        {
            var queryHashes = hashes.Select(_ => _.HashBins).ToList();

            return(queryHashes.Any() ? SubFingerprintDao.ReadSubFingerprints(queryHashes, config) : Enumerable.Empty <SubFingerprintData>());
        }