implemented a simple commit log
This commit is contained in:
parent
80906c85c6
commit
4d1c92641a
44
transaction/commit_log.hpp
Normal file
44
transaction/commit_log.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef MEMGRAPH_TRANSACTION_COMMIT_LOG_HPP
|
||||
#define MEMGRAPH_TRANSACTION_COMMIT_LOG_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <boost/dynamic_bitset/dynamic_bitset.hpp>
|
||||
|
||||
#include "sync/spinlock.hpp"
|
||||
#include "sync/lockable.hpp"
|
||||
|
||||
// optimize allocation performance by preallocating chunks in like 2MB or so
|
||||
// optimize memory by purging old transactions after vacuuming or something
|
||||
// this is not sustainable in the long run
|
||||
|
||||
class CommitLog : Lockable<SpinLock>
|
||||
{
|
||||
void begin()
|
||||
{
|
||||
auto guard = this->acquire();
|
||||
log.push_back(0);
|
||||
}
|
||||
|
||||
void mark_aborted(uint64_t)
|
||||
{
|
||||
// this would be useful in a different implementation
|
||||
}
|
||||
|
||||
void mark_committed(uint64_t id)
|
||||
{
|
||||
auto guard = this->acquire();
|
||||
log.set(id, true);
|
||||
}
|
||||
|
||||
bool is_committed(uint64_t id)
|
||||
{
|
||||
auto guard = this->acquire();
|
||||
return log[id];
|
||||
}
|
||||
|
||||
private:
|
||||
boost::dynamic_bitset<uint64_t> log;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user