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:
@ -21,6 +21,7 @@
|
||||
#include "mu-xapian-db.hh"
|
||||
#include "utils/mu-utils.hh"
|
||||
#include <inttypes.h>
|
||||
#include <mu-config.hh>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
@ -99,17 +100,16 @@ make_db(const std::string& db_path, Flavor flavor)
|
||||
|
||||
XapianDb::XapianDb(const std::string& db_path, Flavor flavor) :
|
||||
path_(make_path(db_path, flavor)),
|
||||
db_(make_db(path_,flavor)) {
|
||||
|
||||
db_(make_db(path_, flavor)),
|
||||
batch_size_{Config(*this).get<Config::Id::BatchSize>()}
|
||||
{
|
||||
if (flavor == Flavor::CreateOverwrite)
|
||||
set_timestamp(MetadataIface::created_key);
|
||||
|
||||
mu_debug("created {} / {}", flavor, *this);
|
||||
mu_debug("created {} / {} (batch-size: {})", flavor, *this, batch_size_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef BUILD_TESTS
|
||||
/*
|
||||
* Tests.
|
||||
|
||||
Reference in New Issue
Block a user