lib: move transaction handling to mu-xapian

Instead of handling transactions in the store, handle it in xapian-db.
Make the code a bit more natural / cleaner-out

Handle transaction automatically (with a batch-size) and add some RAII
Transaction object, which makes all database interaction transactable
for the duration. So, no more need for explicit parameters to
add_message while indexing.
This commit is contained in:
Dirk-Jan C. Binnema
2023-12-13 21:45:04 +02:00
parent cbd6353058
commit 146b80113f
8 changed files with 141 additions and 107 deletions

View File

@ -783,6 +783,8 @@ Server::Private::find_handler(const Command& cmd)
StopWatch sw{mu_format("{} (indexing: {})", __func__,
indexer().is_running() ? "yes" : "no")};
// we need to _lock_ the store while querying (which likely consists of
// multiple actual queries) + grabbing the results.
std::lock_guard l{store_.lock()};
auto qres{store_.run_query(q, sort_field_id, qflags, maxnum)};
if (!qres)
@ -843,7 +845,6 @@ static Sexp
get_stats(const Indexer::Progress& stats, const std::string& state)
{
Sexp sexp;
sexp.put_props(
":info", "index"_sym,
":status", Sexp::Symbol(state),
@ -878,7 +879,6 @@ Server::Private::index_handler(const Command& cmd)
}
output_sexp(get_stats(indexer().progress(), "complete"),
Server::OutputFlags::Flush);
store().commit(); /* ensure on-disk database is updated, too */
});
}