From f20f468faa27bbfc8a82b4a2a7984ac6a5efa0cd Mon Sep 17 00:00:00 2001 From: crx-dev2 <1594837530@qq.com> Date: Thu, 22 Aug 2024 06:53:55 +0000 Subject: [PATCH] add output_file in bc,clce,trustrank_procedure --- procedures/algo_cpp/bc_procedure.cpp | 5 +++++ procedures/algo_cpp/clce_procedure.cpp | 6 ++++++ procedures/algo_cpp/trustrank_procedure.cpp | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/procedures/algo_cpp/bc_procedure.cpp b/procedures/algo_cpp/bc_procedure.cpp index aaaa5242dc..0315bb7bc9 100644 --- a/procedures/algo_cpp/bc_procedure.cpp +++ b/procedures/algo_cpp/bc_procedure.cpp @@ -26,9 +26,11 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re // prepare start_time = get_time(); size_t samples = 10; + std::string output_file = ""; try { json input = json::parse(request); parse_from_json(samples, "samples", input); + parse_from_json(output_file, "output_file", input); } catch (std::exception& e) { response = "json parse error: " + std::string(e.what()); std::cout << response << std::endl; @@ -51,6 +53,9 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re // output start_time = get_time(); + if (output_file != "") { + olapondb.WriteToFile(score, output_file); + } // TODO(any): write score back to graph auto output_cost = get_time() - start_time; diff --git a/procedures/algo_cpp/clce_procedure.cpp b/procedures/algo_cpp/clce_procedure.cpp index 32ffcc44ff..f73f45b4db 100644 --- a/procedures/algo_cpp/clce_procedure.cpp +++ b/procedures/algo_cpp/clce_procedure.cpp @@ -12,6 +12,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +#include #include "lgraph/olap_on_db.h" #include "tools/json.hpp" #include "./algo.h" @@ -26,9 +27,11 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re // prepare start_time = get_time(); size_t samples = 64; + std::string output_file; try { json input = json::parse(request); parse_from_json(samples, "samples", input); + parse_from_json(output_file, "output_file", input); } catch (std::exception& e) { response = "json parse error: " + std::string(e.what()); std::cout << response << std::endl; @@ -62,6 +65,9 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re // output start_time = get_time(); + if (output_file != "") { + olapondb.WriteToFile(score, output_file); + } auto output_cost = get_time() - start_time; // return diff --git a/procedures/algo_cpp/trustrank_procedure.cpp b/procedures/algo_cpp/trustrank_procedure.cpp index 00a41f21ad..6fb8552f22 100644 --- a/procedures/algo_cpp/trustrank_procedure.cpp +++ b/procedures/algo_cpp/trustrank_procedure.cpp @@ -29,12 +29,14 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re std::vector trust_list = {0, 1, 3}; std::string label = "node"; std::string field = "id"; + std::string output_file = ""; try { json input = json::parse(request); parse_from_json(iterations, "iterations", input); parse_from_json(label, "label", input); parse_from_json(field, "field", input); + parse_from_json(output_file, "output_file", input); if (input["trust_list"].is_array()) { trust_list.clear(); } @@ -72,6 +74,9 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re auto field_data = vit.GetField(primary_field); // output start_time = get_time(); + if (output_file != "") { + olapondb.WriteToFile(curr, output_file); + } // TODO(any): write curr back to graph auto output_cost = get_time() - start_time;