Skip to content

Commit

Permalink
perf: add in stats table for faster xfer performance
Browse files Browse the repository at this point in the history
  • Loading branch information
William Silversmith committed Sep 10, 2024
1 parent 07e9f52 commit 7f829fa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cloudfiles/resumable_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ def create(self, src, dest, reencode=None):
""")
cur.execute("CREATE INDEX resumableidxfin ON filelist(finished,lease)")
cur.execute("CREATE INDEX resumableidxfile ON filelist(filename)")

cur.execute(f"""
CREATE TABLE stats (
id {INTEGER} PRIMARY KEY {AUTOINC},
key TEXT NOT NULL,
value {INTEGER}
)
""")
cur.execute(
"INSERT INTO stats(id, key, value) VALUES (?,?,?)",
[1, 'finished', 0]
)
cur.close()

def insert(self, fname_iter):
Expand Down Expand Up @@ -116,6 +128,7 @@ def mark_finished(self, fname_iter):
for filenames in sip(fname_iter, SQLITE_MAX_PARAMS):
bindlist = ",".join([f"{BIND}"] * len(filenames))
cur.execute(f"UPDATE filelist SET finished = 1 WHERE filename in ({bindlist})", filenames)
cur.execute(f"UPDATE stats SET value = value + {len(filenames)} WHERE id = 1")
cur.execute("commit")
cur.close()

Expand Down

0 comments on commit 7f829fa

Please sign in to comment.