Skip to content

Commit

Permalink
fix(interactive): Incorporating the builtin procedure's metadata into…
Browse files Browse the repository at this point in the history
… the schema's plugin map (#4289)

The meta info about builtin procedure should also be put in schema's
fields.
  • Loading branch information
zhanglei1949 authored Oct 16, 2024
1 parent 7734584 commit 0aa119e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
9 changes: 7 additions & 2 deletions flex/engines/graph_db/database/graph_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,14 @@ void GraphDB::initApps(
size_t valid_plugins = 0;
for (auto& path_and_index : plugins) {
auto path = path_and_index.second.first;
auto name = path_and_index.first;
auto index = path_and_index.second.second;
if (registerApp(path, index)) {
++valid_plugins;
if (!Schema::IsBuiltinPlugin(name)) {
if (registerApp(path, index)) {
++valid_plugins;
}
} else {
valid_plugins++;
}
}
LOG(INFO) << "Successfully registered stored procedures : " << valid_plugins
Expand Down
9 changes: 9 additions & 0 deletions flex/engines/graph_db/database/graph_db_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ double GraphDBSession::eval_duration() const {

int64_t GraphDBSession::query_num() const { return query_num_.load(); }

AppBase* GraphDBSession::GetApp(const std::string& app_name) {
auto& app_name_to_path_index = db_.schema().GetPlugins();
if (app_name_to_path_index.count(app_name) <= 0) {
LOG(ERROR) << "Query name is not registered: " << app_name;
return nullptr;
}
return GetApp(app_name_to_path_index.at(app_name).second);
}

#define likely(x) __builtin_expect(!!(x), 1)

AppBase* GraphDBSession::GetApp(int type) {
Expand Down
2 changes: 2 additions & 0 deletions flex/engines/graph_db/database/graph_db_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class GraphDBSession {

AppBase* GetApp(int idx);

AppBase* GetApp(const std::string& name);

private:
Result<std::pair<uint8_t, std::string_view>>
parse_query_type_from_cypher_json(const std::string_view& input);
Expand Down
13 changes: 13 additions & 0 deletions flex/storages/rt_mutable_graph/schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,19 @@ bool Schema::EmplacePlugins(
<< ", name or library not found.";
}
}
// Emplace the built-in plugins
plugin_name_to_path_and_id_.emplace(
Schema::BUILTIN_COUNT_VERTICES_PLUGIN_NAME,
std::make_pair("", Schema::BUILTIN_COUNT_VERTICES_PLUGIN_ID));
plugin_name_to_path_and_id_.emplace(
Schema::BUILTIN_PAGERANK_PLUGIN_NAME,
std::make_pair("", Schema::BUILTIN_PAGERANK_PLUGIN_ID));
plugin_name_to_path_and_id_.emplace(
Schema::BUILTIN_K_DEGREE_NEIGHBORS_PLUGIN_NAME,
std::make_pair("", Schema::BUILTIN_K_DEGREE_NEIGHBORS_PLUGIN_ID));
plugin_name_to_path_and_id_.emplace(
Schema::BUILTIN_TVSP_PLUGIN_NAME,
std::make_pair("", Schema::BUILTIN_TVSP_PLUGIN_ID));

LOG(INFO) << "Load " << plugin_name_to_path_and_id_.size() << " plugins";
return true;
Expand Down

0 comments on commit 0aa119e

Please sign in to comment.