public void SetUp() { var ramStorage = new RAMStorage(NumberOfHashTables); fingerprintDao = new FingerprintDao(ramStorage); trackDao = new TrackDao(ramStorage); }
public void SetUp() { var ramStorage = new RAMStorage(NumberOfHashTables); ModelService = new InMemoryModelService( new TrackDao(ramStorage), new HashBinDao(ramStorage), new SubFingerprintDao(ramStorage), new FingerprintDao(ramStorage), new SpectralImageDao()); }
public void SetUp() { var ramStorage = new RAMStorage(25); subFingerprintDao = new SubFingerprintDao(ramStorage, new StandardGroupingCounter()); trackDao = new TrackDao(ramStorage); }
public void ShouldInsertEntriesInThreadSafeManner() { var storage = new RAMStorage(50); var hashConverter = new HashConverter(); var hashes = Enumerable.Range(0, 100).Select(b => (byte)b).ToArray(); var longs = hashConverter.ToInts(hashes, 25); int tracksCount = 520; int subFingerprintsPerTrack = 33; float one = 8192f / 5512; Parallel.For(0, tracksCount, i => { var trackReference = new ModelReference <int>(i); for (int j = 0; j < subFingerprintsPerTrack; ++j) { var hashed = new HashedFingerprint(longs, (uint)j, j * one, Array.Empty <byte>()); storage.AddHashedFingerprint(hashed, trackReference); } }); for (int i = 0; i < 25; ++i) { var subFingerprints = storage.GetSubFingerprintsByHashTableAndHash(i, longs[i]); Assert.AreEqual(tracksCount * subFingerprintsPerTrack, subFingerprints.Count); } }
public void DistributionOfHashesHasToBeUniform() { var lshAlgorithm = LocalitySensitiveHashingAlgorithm.Instance; var random = new Random(); var storage = new RAMStorage(25); float one = 8192f / 5512; var config = new DefaultHashingConfig { NumberOfLSHTables = 25, NumberOfMinHashesPerTable = 4, HashBuckets = 0 }; var track = new ModelReference <int>(1); int l = 100000; for (int i = 0; i < l; ++i) { var schema = TestUtilities.GenerateRandomFingerprint(random, 200, 128, 32); var hash = lshAlgorithm.Hash(new Fingerprint(schema, i * one, (uint)i, Array.Empty <byte>()), config); var subFingerprint = new SubFingerprintData(hash.HashBins, hash.SequenceNumber, hash.StartsAt, new ModelReference <uint>((uint)i), track); storage.AddSubFingerprint(subFingerprint); } var distribution = storage.HashCountsPerTable; foreach (var hashPerTable in distribution) { double collisions = (double)(l - hashPerTable) / l; Assert.IsTrue(collisions <= 0.01d, $"Less than 1% of collisions across 100K hashes: {collisions}"); } }
public void FingerprintsCantMatchUniformlyAtRandom() { var lshAlgorithm = LocalitySensitiveHashingAlgorithm.Instance; var random = new Random(); var storage = new RAMStorage(25); float one = 8192f / 5512; var config = new DefaultHashingConfig { NumberOfLSHTables = 25, NumberOfMinHashesPerTable = 4, HashBuckets = 0 }; var track = new ModelReference <int>(1); for (int i = 0; i < 100; ++i) { var schema = TestUtilities.GenerateRandomFingerprint(random, 200, 128, 32); var hash = lshAlgorithm.Hash(new Fingerprint(schema, i * one, (uint)i, Array.Empty <byte>()), config); var subFingerprint = new SubFingerprintData(hash.HashBins, hash.SequenceNumber, hash.StartsAt, new ModelReference <uint>((uint)i), track); storage.AddSubFingerprint(subFingerprint); } for (int i = 0; i < 10; ++i) { var schema = TestUtilities.GenerateRandomFingerprint(random, 200, 128, 32); var hash = lshAlgorithm.Hash(new Fingerprint(schema, i * one, (uint)i, Array.Empty <byte>()), config); for (int j = 0; j < 25; ++j) { var ids = storage.GetSubFingerprintsByHashTableAndHash(j, hash.HashBins[j]); Assert.IsFalse(ids.Any()); } } }
public void SetUp() { var ramStorage = new RAMStorage(NumberOfFingerprints); SubFingerprintDao = new SubFingerprintDao(ramStorage); TrackDao = new TrackDao(ramStorage); }
public void SetUp() { var ramStorage = new RAMStorage(NumberOfHashTables); HashBinDao = new HashBinDao(ramStorage); TrackDao = new TrackDao(ramStorage); SubFingerprintDao = new SubFingerprintDao(ramStorage); }
public void SetUp() { var storage = new RAMStorage(25); spectralImageDao = new SpectralImageDao(storage); }
public void SetUp() { var storage = new RAMStorage(25); spectralImageDao = new SpectralImageDao(storage); }