From 30aaefca64445efa421edb93403036d59382920f Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 8 Aug 2024 14:35:53 +1000 Subject: Batch up the db operations associated with adding new tracks This is ostensibly yet another 'prepare for multithreaded updates' commit, however it does actually save us another 60(!!) odd milliseconds per track. --- src/tangara/database/database.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/tangara/database/database.hpp') diff --git a/src/tangara/database/database.hpp b/src/tangara/database/database.hpp index 2b385013..39665dbf 100644 --- a/src/tangara/database/database.hpp +++ b/src/tangara/database/database.hpp @@ -29,6 +29,7 @@ #include "leveldb/iterator.h" #include "leveldb/options.h" #include "leveldb/slice.h" +#include "leveldb/write_batch.h" #include "memory_resource.hpp" #include "result.hpp" #include "tasks.hpp" @@ -111,17 +112,18 @@ class Database { auto dbCalculateNextTrackId() -> void; auto dbMintNewTrackId() -> TrackId; - auto dbEntomb(TrackId track, uint64_t hash) -> void; - auto dbPutTrackData(const TrackData& s) -> void; auto dbGetTrackData(TrackId id) -> std::shared_ptr; - auto dbPutHash(const uint64_t& hash, TrackId i) -> void; - auto dbGetHash(const uint64_t& hash) -> std::optional; - auto dbCreateIndexesForTrack(const Track& track) -> void; + auto dbCreateIndexesForTrack(const Track&, leveldb::WriteBatch&) -> void; + auto dbCreateIndexesForTrack(const TrackData&, + const TrackTags&, + leveldb::WriteBatch&) -> void; + auto dbRemoveIndexes(std::shared_ptr) -> void; auto dbIngestTagHashes(const TrackTags&, - std::pmr::unordered_map&) -> void; + std::pmr::unordered_map&, + leveldb::WriteBatch&) -> void; auto dbRecoverTagsFromHashes(const std::pmr::unordered_map&) -> std::shared_ptr; -- cgit v1.2.3