Skip to content

Commit

Permalink
add output_file in bc,clce,trustrank_procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
ncbd committed Aug 22, 2024
1 parent dc92dac commit f20f468
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions procedures/algo_cpp/bc_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<double>(score, output_file);
}
// TODO(any): write score back to graph
auto output_cost = get_time() - start_time;

Expand Down
6 changes: 6 additions & 0 deletions procedures/algo_cpp/clce_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/

#include <string>
#include "lgraph/olap_on_db.h"
#include "tools/json.hpp"
#include "./algo.h"
Expand All @@ -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;
Expand Down Expand Up @@ -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<double>(score, output_file);
}
auto output_cost = get_time() - start_time;

// return
Expand Down
5 changes: 5 additions & 0 deletions procedures/algo_cpp/trustrank_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ extern "C" bool Process(GraphDB& db, const std::string& request, std::string& re
std::vector<int64_t> 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();
}
Expand Down Expand Up @@ -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<double>(curr, output_file);
}
// TODO(any): write curr back to graph
auto output_cost = get_time() - start_time;

Expand Down

0 comments on commit f20f468

Please sign in to comment.