memgraph/include/transactions/snapshot.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

45 lines
935 B
C++

#pragma once
#include <algorithm>
#include <vector>
namespace tx
{
template <class id_t>
class Snapshot
{
public:
Snapshot() = default;
Snapshot(std::vector<id_t> active) : active(std::move(active)) {}
Snapshot(const Snapshot &other) { active = other.active; }
Snapshot(Snapshot &&other) { active = std::move(other.active); }
bool is_active(id_t xid) const
{
return std::binary_search(active.begin(), active.end(), xid);
}
void insert(const id_t &id) { active.push_back(id); }
void remove(const id_t &id)
{
// remove transaction from the active transactions list
auto last = std::remove(active.begin(), active.end(), id);
active.erase(last, active.end());
}
const id_t &front() { return active.front(); }
const id_t &back() { return active.back(); }
size_t size() { return active.size(); }
private:
std::vector<id_t> active;
};
}