2016-07-05 11:01:22 +08:00
|
|
|
#pragma once
|
|
|
|
|
2016-08-18 22:34:36 +08:00
|
|
|
#include <string>
|
2016-08-25 22:29:45 +08:00
|
|
|
|
2016-07-05 11:01:22 +08:00
|
|
|
#include "data_structures/concurrent/concurrent_map.hpp"
|
2016-08-25 22:29:45 +08:00
|
|
|
#include "utils/counters/atomic_counter.hpp"
|
2016-08-15 07:09:58 +08:00
|
|
|
#include "utils/option.hpp"
|
2016-07-05 11:01:22 +08:00
|
|
|
|
2016-08-25 22:29:45 +08:00
|
|
|
#include "storage/model/properties/property_family.hpp"
|
|
|
|
#include "storage/vertex_record.hpp"
|
|
|
|
|
2016-08-18 22:34:36 +08:00
|
|
|
class DbTransaction;
|
2016-08-25 22:29:45 +08:00
|
|
|
class VertexAccessor;
|
|
|
|
|
|
|
|
using VertexPropertyFamily = PropertyFamily<TypeGroupVertex>;
|
2016-08-28 22:47:13 +08:00
|
|
|
template <class K>
|
|
|
|
using VertexIndexBase = IndexBase<TypeGroupVertex, K>;
|
2016-07-05 11:01:22 +08:00
|
|
|
|
|
|
|
class Vertices
|
|
|
|
{
|
|
|
|
public:
|
2016-08-08 16:32:34 +08:00
|
|
|
using vertices_t = ConcurrentMap<uint64_t, VertexRecord>;
|
2016-08-18 22:34:36 +08:00
|
|
|
using prop_familys_t =
|
2016-08-25 22:29:45 +08:00
|
|
|
ConcurrentMap<std::string, std::unique_ptr<VertexPropertyFamily>>;
|
2016-08-08 16:32:34 +08:00
|
|
|
|
|
|
|
vertices_t::Accessor access();
|
|
|
|
|
2016-08-25 22:29:45 +08:00
|
|
|
Option<const VertexAccessor> find(DbTransaction &t, const Id &id);
|
2016-08-08 16:32:34 +08:00
|
|
|
|
2016-08-25 22:29:45 +08:00
|
|
|
// Creates new Vertex and returns filled VertexAccessor.
|
|
|
|
VertexAccessor insert(DbTransaction &t);
|
2016-07-05 11:01:22 +08:00
|
|
|
|
2016-08-30 08:01:03 +08:00
|
|
|
// TODO: how can I know how many elements exist
|
|
|
|
// without iterating through all of them? MVCC?
|
|
|
|
|
2016-08-25 22:29:45 +08:00
|
|
|
VertexPropertyFamily &
|
|
|
|
property_family_find_or_create(const std::string &name);
|
2016-08-13 06:01:39 +08:00
|
|
|
|
2016-08-30 07:45:07 +08:00
|
|
|
prop_familys_t::Accessor property_family_access();
|
|
|
|
|
2016-07-05 11:01:22 +08:00
|
|
|
private:
|
2016-08-19 00:43:06 +08:00
|
|
|
// TODO: Because families wont be removed this could be done with more
|
2016-08-18 22:34:36 +08:00
|
|
|
// efficent
|
|
|
|
// data structure.
|
|
|
|
prop_familys_t prop_familys;
|
2016-09-05 22:56:08 +08:00
|
|
|
|
|
|
|
// NOTE: this must be before prop_familys field to be destroyed before them.
|
|
|
|
// Because there are property_family references in vertices.
|
|
|
|
vertices_t vertices;
|
|
|
|
|
2016-07-05 11:01:22 +08:00
|
|
|
AtomicCounter<uint64_t> counter;
|
|
|
|
};
|