96ece11cdd
Summary: This change introduces a pure virtual initial implementation of the transaction engine which is then implemented in two versions: single node and distributed. The interface classes now have the following hierarchy: ``` Engine (pure interface) | +----+---------- EngineDistributed (common logic) | | EngineSingleNode +-------+--------+ | | EngineMaster EngineWorker ``` In addition to this layout the `EngineMaster` uses `EngineSingleNode` as its underlying storage engine and only changes the necessary functions to make them work with the `EngineWorker`. After this change I recommend that you delete the following leftover files: ``` rm src/distributed/transactional_cache_cleaner_rpc_messages.* rm src/transactions/common.* rm src/transactions/engine_rpc_messages.* ``` Reviewers: teon.banek, msantl, buda Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1589
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "mvcc/record.hpp"
|
|
#include "transactions/single_node/engine_single_node.hpp"
|
|
|
|
/**
|
|
* @brief - Empty class which inherits from mvcc:Record.
|
|
*/
|
|
class Prop : public mvcc::Record<Prop> {
|
|
public:
|
|
Prop *CloneData() { return new Prop; }
|
|
};
|
|
|
|
/**
|
|
* @brief - Class which inherits from mvcc::Record and takes an atomic variable
|
|
* to count number of destructor calls (to test if the record is actually
|
|
* deleted).
|
|
*/
|
|
class DestrCountRec : public mvcc::Record<DestrCountRec> {
|
|
public:
|
|
explicit DestrCountRec(std::atomic<int> &count) : count_(count) {}
|
|
DestrCountRec *CloneData() { return new DestrCountRec(count_); }
|
|
~DestrCountRec() { ++count_; }
|
|
|
|
private:
|
|
std::atomic<int> &count_;
|
|
};
|
|
|
|
// helper function for creating a GC snapshot
|
|
// if given a nullptr it makes a GC snapshot like there
|
|
// are no active transactions
|
|
auto GcSnapshot(tx::EngineSingleNode &engine, tx::Transaction *t) {
|
|
if (t != nullptr) {
|
|
tx::Snapshot gc_snap = t->snapshot();
|
|
gc_snap.insert(t->id_);
|
|
return gc_snap;
|
|
} else {
|
|
return engine.GlobalGcSnapshot();
|
|
}
|
|
}
|