Go to the documentation of this file.
16 #ifndef GRAPHSCOPE_DATABASE_GRAPH_DB_H_
17 #define GRAPHSCOPE_DATABASE_GRAPH_DB_H_
23 #include <shared_mutex>
42 struct SessionLocalContext;
46 const std::string& compiler_path_ =
"",
int thread_num_ = 1)
74 bool get(
const std::string& key, std::string_view& value) {
75 std::shared_lock<std::shared_mutex> lock(
mutex);
76 auto it =
cache.find(key);
77 if (it !=
cache.end()) {
84 void put(
const std::string& key,
const std::string_view& value) {
85 std::unique_lock<std::shared_mutex> lock(
mutex);
89 std::unordered_map<std::string, std::string>
cache;
108 int32_t thread_num = 1,
bool warmup =
false,
109 bool memory_only =
true,
110 bool enable_auto_compaction =
false);
160 uint8_t label,
const std::string& col_name)
const {
165 uint8_t label)
const {
188 bool registerApp(
const std::string& path, uint8_t index = 0);
190 void ingestWals(
const std::vector<std::string>& wals,
191 const std::string&
work_dir,
int thread_num);
194 const std::unordered_map<std::string, std::pair<std::string, uint8_t>>&
229 #endif // GRAPHSCOPE_DATABASE_GRAPH_DB_H_
MemoryStrategy
Definition: mmap_array.h:58
std::shared_ptr< ColumnBase > get_vertex_property_column(uint8_t label, const std::string &col_name) const
Definition: graph_db.h:159
Table & get_vertex_table(label_t vertex_label)
Definition: mutable_property_fragment.h:67
SessionLocalContext * contexts_
Definition: graph_db.h:207
Definition: graph_db.h:73
const MutablePropertyFragment & graph() const
Definition: graph_db.h:154
uint32_t timestamp_t
Definition: types.h:30
std::string work_dir() const
Definition: graph_db.h:183
bool monitor_thread_running_
Definition: graph_db.h:220
int thread_num
Definition: graph_db.h:59
bool get(const std::string &key, std::string_view &value)
Definition: graph_db.h:74
const Schema & schema() const
Definition: mutable_property_fragment.cc:388
static GraphDB & get()
Definition: graph_db.cc:68
GraphDBSession & GetSession(int thread_id)
Definition: graph_db.cc:292
void showAppMetrics() const
Definition: graph_db.cc:483
Definition: insert_transaction.h:33
std::shared_ptr< RefColumnBase > get_vertex_id_column(uint8_t label) const
Definition: mutable_property_fragment.h:139
int thread_num_
Definition: graph_db.h:209
AppWrapper CreateApp(uint8_t app_type, int thread_id)
Definition: graph_db.cc:309
Definition: adj_list.h:23
std::thread monitor_thread_
Definition: graph_db.h:219
UpdateTransaction GetUpdateTransaction(int thread_id=0)
Create a transaction to update vertices and edges.
Definition: graph_db.cc:288
std::unordered_map< std::string, std::string > cache
Definition: graph_db.h:89
int SessionNum() const
Definition: graph_db.cc:300
VersionManager version_manager_
Definition: graph_db.h:212
Definition: graph_db.cc:34
bool registerApp(const std::string &path, uint8_t index=0)
Definition: graph_db.cc:319
Result< bool > Open(const Schema &schema, const std::string &data_dir, int32_t thread_num=1, bool warmup=false, bool memory_only=true, bool enable_auto_compaction=false)
Load the graph from data directory.
Definition: graph_db.cc:73
Definition: app_utils.h:25
bool enable_monitoring
Definition: graph_db.h:61
Definition: single_edge_insert_transaction.h:30
std::shared_mutex mutex
Definition: graph_db.h:88
void GetAppInfo(Encoder &result)
Definition: graph_db.cc:335
Definition: mutable_property_fragment.h:37
MutablePropertyFragment graph_
Definition: graph_db.h:211
SingleVertexInsertTransaction GetSingleVertexInsertTransaction(int thread_id=0)
Create a transaction to insert a single vertex.
Definition: graph_db.cc:278
bool warmup
Definition: graph_db.h:60
QueryCache query_cache_
Definition: graph_db.h:217
void openWalAndCreateContexts(const std::string &data_dir_path, MemoryStrategy allocator_strategy)
Definition: graph_db.cc:454
std::array< std::shared_ptr< AppFactoryBase >, 256 > app_factories_
Definition: graph_db.h:215
bool enable_auto_compaction
Definition: graph_db.h:62
Definition: graph_db_session.h:36
Definition: graph_db.h:92
GraphDBConfig(const Schema &schema_, const std::string &data_dir_, const std::string &compiler_path_="", int thread_num_=1)
Definition: graph_db.h:45
void ingestWals(const std::vector< std::string > &wals, const std::string &work_dir, int thread_num)
Definition: graph_db.cc:374
std::string compiler_path
Definition: graph_db.h:58
Definition: version_manager.h:34
size_t getExecutedQueryNum() const
Definition: graph_db.cc:502
std::thread compact_thread_
Definition: graph_db.h:224
int memory_level
Definition: graph_db.h:70
Definition: read_transaction.h:311
void put(const std::string &key, const std::string_view &value)
Definition: graph_db.h:84
Definition: single_vertex_insert_transaction.h:30
Schema schema
Definition: graph_db.h:56
std::string data_dir
Definition: graph_db.h:57
void initApps(const std::unordered_map< std::string, std::pair< std::string, uint8_t >> &plugins)
Definition: graph_db.cc:399
const Schema & schema() const
Definition: graph_db.h:157
ReadTransaction GetReadTransaction(int thread_id=0)
Create a transaction to read vertices and edges.
Definition: graph_db.cc:270
SingleEdgeInsertTransaction GetSingleEdgeInsertTransaction(int thread_id=0)
Create a transaction to insert a single edge.
Definition: graph_db.cc:283
void Close()
Close the current opened graph.
Definition: graph_db.cc:247
bool compact_thread_running_
Definition: graph_db.h:223
std::array< std::string, 256 > app_paths_
Definition: graph_db.h:214
~GraphDB()
Definition: graph_db.cc:53
Definition: app_base.h:78
std::shared_ptr< RefColumnBase > get_vertex_id_column(uint8_t label) const
Definition: graph_db.h:164
Definition: update_transaction.h:38
MutablePropertyFragment & graph()
Definition: graph_db.h:155
InsertTransaction GetInsertTransaction(int thread_id=0)
Create a transaction to insert vertices and edges with a default allocator.
Definition: graph_db.cc:274
timestamp_t GetLastCompactionTimestamp() const
Definition: graph_db.cc:305
Definition: graph_db.h:44
std::string work_dir_
Definition: graph_db.h:206
timestamp_t last_compaction_ts_
Definition: graph_db.h:222
std::shared_ptr< ColumnBase > get_column(const std::string &name)
Definition: table.cc:171
void UpdateCompactionTimestamp(timestamp_t ts)
Definition: graph_db.cc:302
QueryCache & getQueryCache() const
Definition: graph_db.cc:510
void OutputCypherProfiles(const std::string &prefix)
Definition: graph_db.cc:512