Skip to content
Snippets Groups Projects
Commit df2c003e authored by ale's avatar ale
Browse files

query fingerprints in a more efficient way

parent 38527b7f
Branches
No related tags found
No related merge requests found
......@@ -64,15 +64,16 @@ class DeDuper(object):
log.debug('loading in-memory fingerprint database...')
start = time.time()
fp.erase_database(local=True, really_delete=True)
mp3s = MP3.query.filter(
(MP3.artist == u'bonobo')
& (MP3.state == MP3.READY)
& (MP3.has_fingerprint == True))
for mp3 in mp3s:
code = self._generate_code_json(mp3.echoprint_fp, mp3.sha1)
# Skip the ORM and directly query the SQL layer.
q = select([Fingerprint.sha1, Fingerprint.echoprint_fp],
(MP3.sha1 == Fingerprint.sha1)
& (MP3.state == MP3.READY)
& (MP3.has_fingerprint == True))
for row in engine.execute(q):
code = self._generate_code_json(row.echoprint_fp, row.sha1)
if not code:
continue
self.codes[mp3.sha1] = code['fp']
self.codes[row.sha1] = code['fp']
fp.ingest(code, do_commit=False, local=True)
elapsed = time.time() - start
log.debug('loaded in-memory fingerprint database in %g seconds' % elapsed)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment