diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-07-24 07:20:19 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-07-24 07:20:19 +0200 |
commit | 32f406706c0a2a21b11656e5c56ff203e0ee3799 (patch) | |
tree | bd74f64b487c48b1817c65307641c53be83cfad9 | |
parent | 2f797c9b90f05eadf4bb13f4a9c1f029925d9275 (diff) | |
download | debian-dedup-32f406706c0a2a21b11656e5c56ff203e0ee3799.tar.gz |
readyaml: cache the whole function table
This should reduce the query bandwidth to the rdbms.
-rwxr-xr-x | readyaml.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/readyaml.py b/readyaml.py index f4d6ead..21b1ca1 100755 --- a/readyaml.py +++ b/readyaml.py @@ -25,6 +25,8 @@ def readyaml(db, stream): pid = None cur.execute("BEGIN;") + cur.execute("SELECT name, id FROM function;") + funcmapping = dict(cur.fetchall()) if pid is not None: cur.execute("DELETE FROM content WHERE pid = ?;", (pid,)) cur.execute("DELETE FROM dependency WHERE pid = ?;", (pid,)) @@ -45,8 +47,8 @@ def readyaml(db, stream): cur.execute("INSERT INTO content (pid, filename, size) VALUES (?, ?, ?);", (pid, entry["name"], entry["size"])) cid = cur.lastrowid - cur.executemany("INSERT INTO hash (cid, fid, hash) VALUES (?, (SELECT id FROM function WHERE name = ?), ?);", - ((cid, func, hexhash) + cur.executemany("INSERT INTO hash (cid, fid, hash) VALUES (?, ?, ?);", + ((cid, funcmapping[func], hexhash) for func, hexhash in entry["hashes"].items())) raise ValueError("missing commit block") |