store/indexer: move transaction handling to store

Move the transaction handling code inside Store, simplifying the indexer.
This commit is contained in:
Dirk-Jan C. Binnema
2021-11-09 22:43:11 +02:00
parent 48d3f9cfab
commit 4c0d8572d8
3 changed files with 56 additions and 78 deletions

View File

@ -136,13 +136,16 @@ public:
Indexer& indexer();
/**
* Add a message to the store.
* Add a message to the store. When planning to write many messages,
* it's much faster to do so in a transaction. If so, set
* @in_transaction to true. When done with adding messages, call commit().
*
* @param path the message path.
* @param whether to bundle up to batch_size changes in a transaction
*
* @return the doc id of the added message
*/
Id add_message(const std::string& path);
Id add_message(const std::string& path, bool use_transaction = false);
/**
* Update a message in the store.
@ -279,17 +282,10 @@ public:
bool empty() const;
/**
* Start a Xapian transaction, opportunistically. If a transaction
* is already underway, do nothing.
* Commit the current batch of modifications to disk, opportunistically.
* If no transaction is underway, do nothing.
*/
void begin_transaction();
/**
* Commit the current group of modifications (i.e., transaction) to
* disk, opportunistically. If no transaction is underway, do
* nothing.
*/
void commit_transaction();
void commit();
/**
* Get a reference to the private data. For internal use.