2017-02-04 16:01:15 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "data_structures/concurrent/skiplist.hpp"
|
|
|
|
#include "transactions/engine.hpp"
|
|
|
|
#include "mvcc/version_list.hpp"
|
|
|
|
#include "utils/pass_key.hpp"
|
2017-02-11 14:51:02 +08:00
|
|
|
#include "data_structures/concurrent/concurrent_set.hpp"
|
2017-02-06 19:40:55 +08:00
|
|
|
#include "storage/unique_object_store.hpp"
|
2017-02-04 16:01:15 +08:00
|
|
|
|
|
|
|
// forward declaring Edge and Vertex because they use
|
|
|
|
// GraphDb::Label etc., and therefore include this header
|
|
|
|
class Vertex;
|
|
|
|
class VertexAccessor;
|
|
|
|
class Edge;
|
|
|
|
class EdgeAccessor;
|
|
|
|
|
|
|
|
// TODO: Maybe split this in another layer between Db and Dbms. Where the new
|
|
|
|
// layer would hold SnapshotEngine and his kind of concept objects. Some
|
|
|
|
// guidelines would be: retain objects which are necessary to implement querys
|
|
|
|
// in Db, the rest can be moved to the new layer.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main class which represents Database concept in code.
|
|
|
|
*/
|
|
|
|
class GraphDb {
|
2017-02-06 19:40:55 +08:00
|
|
|
|
2017-02-04 16:01:15 +08:00
|
|
|
public:
|
|
|
|
|
|
|
|
// definitions for what data types are used for a Label, Property, EdgeType
|
2017-02-11 14:51:02 +08:00
|
|
|
using Label = std::string*;
|
|
|
|
using EdgeType = std::string*;
|
|
|
|
using Property = std::string*;
|
2017-02-04 16:01:15 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct database with a custom name.
|
|
|
|
*
|
|
|
|
* @param name database name
|
|
|
|
* @param import_snapshot will in constructor import latest snapshot
|
|
|
|
* into the db.
|
|
|
|
*/
|
|
|
|
GraphDb(const std::string &name, bool import_snapshot = true);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Database object can't be copied.
|
|
|
|
*/
|
|
|
|
GraphDb(const GraphDb &db) = delete;
|
|
|
|
|
|
|
|
/** transaction engine related to this database */
|
|
|
|
tx::Engine tx_engine;
|
|
|
|
|
|
|
|
/** garbage collector related to this database*/
|
|
|
|
// TODO bring back garbage collection
|
|
|
|
// Garbage garbage = {tx_engine};
|
|
|
|
|
|
|
|
// TODO bring back shapshot engine
|
|
|
|
// SnapshotEngine snap_engine = {*this};
|
|
|
|
|
|
|
|
// database name
|
2017-02-06 19:40:55 +08:00
|
|
|
// TODO consider if this is even necessary
|
2017-02-04 16:01:15 +08:00
|
|
|
const std::string name_;
|
|
|
|
|
|
|
|
// main storage for the graph
|
|
|
|
SkipList<mvcc::VersionList<Vertex>*> vertices_;
|
2017-02-15 21:10:16 +08:00
|
|
|
SkipList<mvcc::VersionList<Edge>*> edges_;
|
2017-02-04 16:01:15 +08:00
|
|
|
|
2017-02-06 19:40:55 +08:00
|
|
|
// unique object stores
|
2017-02-11 14:51:02 +08:00
|
|
|
ConcurrentSet<std::string> labels_;
|
|
|
|
ConcurrentSet<std::string> edge_types_;
|
|
|
|
ConcurrentSet<std::string> properties_;
|
2017-02-04 16:01:15 +08:00
|
|
|
};
|