Testing delayed insertions of representations

This commit is contained in:
Ozbolt Menegatti 2019-09-11 08:58:02 +02:00
parent 6bb3586051
commit 8fee3f8a8e

View File

@ -96,16 +96,24 @@ class MatchStore:
print("Representation step already done, skipping") print("Representation step already done, skipping")
return return
num_inserts = 1000
inserts = []
structures_dict = {s.id: s for s in structures} structures_dict = {s.id: s for s in structures}
num_representations = int(self.db.execute("SELECT Count(*) FROM Colocations").fetchone()[0]) num_representations = int(self.db.execute("SELECT Count(*) FROM Colocations").fetchone()[0])
for cid, sid in progress(self.db.execute("SELECT colocation_id, structure_id FROM Colocations"), "representations", total=num_representations): for cid, sid in progress(self.db.execute("SELECT colocation_id, structure_id FROM Colocations"), "representations", total=num_representations):
structure = structures_dict[sid] structure = structures_dict[sid]
match = StructureMatch.from_db(self.db, cid, structure) match = StructureMatch.from_db(self.db, cid, structure)
RepresentationAssigner.set_representations(match, word_renderer) RepresentationAssigner.set_representations(match, word_renderer)
inserts.append(match)
if len(inserts) > num_inserts:
for match in inserts:
for component_id, text in match.representations.items(): for component_id, text in match.representations.items():
self.db.execute(""" self.db.execute("""
INSERT INTO Representations (colocation_id, component_id, text) INSERT INTO Representations (colocation_id, component_id, text)
VALUES (?,?,?)""", (match.match_id, component_id, text)) VALUES (?,?,?)""", (match.match_id, component_id, text))
inserts = []
self.db.step_is_done(step_name) self.db.step_is_done(step_name)