Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use in memory db to speed the merge #1

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions testmon/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ def merge_dbs(merged_datafile, db_1: "DB", db_2: "DB") -> "DB":
if db_1.env != db_2.env:
raise

merged_db = DB(merged_datafile, environment=db_1.env)
with merged_db:
memory_db = DB(":memory:", environment=db_1.env)
file_db = DB(merged_datafile, environment=db_1.env)
with memory_db:
with db_1:
for data in db_1.all_data():
merged_db.insert_node_fingerprints(data["name"], fingerprints=[data], failed=data["failed"],
memory_db.insert_node_fingerprints(data["name"], fingerprints=[data], failed=data["failed"],
duration=data["duration"])

with db_2:
for data in db_2.all_data():
merged_db.insert_node_fingerprints(data["name"], fingerprints=[data], failed=data["failed"],
memory_db.insert_node_fingerprints(data["name"], fingerprints=[data], failed=data["failed"],
duration=data["duration"])

return merged_db
with file_db:
memory_db.con.backup(file_db.con)

return file_db


class DB:
Expand Down Expand Up @@ -324,7 +328,7 @@ def filenames_fingerprints(self):
def all_data(self) -> List[dict]:
cursor = self.con.execute(
"""
SELECT
SELECT
n.name,
n.duration,
n.failed,
Expand Down