memgraph/include/transactions/commit_log.hpp
Kruno Tomola Fabro 8a89f6601d EdgeType indexes added.
Implemented untested UniqueOrderedIndex.

Introduced TypeGroupEdge/Vertex into database.

Added Index capabilityes to PropertyFamily.
Added method for adding index.
Added method for removing index.
2016-08-25 15:29:45 +01:00

57 lines
1.4 KiB
C++

#pragma once
#include "data_structures/bitset/dynamic_bitset.hpp"
#include "mvcc/id.hpp"
namespace tx
{
class CommitLog
{
public:
struct Info
{
enum Status
{
ACTIVE = 0, // 00
COMMITTED = 1, // 01
ABORTED = 2, // 10
};
bool is_active() const { return flags & ACTIVE; }
bool is_committed() const { return flags & COMMITTED; }
bool is_aborted() const { return flags & ABORTED; }
operator uint8_t() const { return flags; }
uint8_t flags;
};
CommitLog() = default;
CommitLog(CommitLog &) = delete;
CommitLog(CommitLog &&) = delete;
CommitLog operator=(CommitLog) = delete;
Info fetch_info(const Id &id) { return Info{log.at(2 * id, 2)}; }
bool is_active(const Id &id) { return fetch_info(id).is_active(); }
bool is_committed(const Id &id) { return fetch_info(id).is_committed(); }
void set_committed(const Id &id) { log.set(2 * id); }
bool is_aborted(const Id &id) { return fetch_info(id).is_aborted(); }
void set_aborted(const Id &id) { log.set(2 * id + 1); }
private:
// TODO: Searching the log will take more and more time the more and more
// transactoins are done. This could be awerted if DynamicBitset is changed
// to point to largest chunk instead of the smallest.
DynamicBitset<uint8_t, 32768> log;
};
}