Skip to content

Commit

Permalink
Update recursive_graph_bisection.cpp (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
amallia authored Jun 6, 2019
1 parent 8a53823 commit 5b4cacb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/recursive_graph_bisection.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <numeric>
#include <thread>
#include <optional>

#include <CLI/CLI.hpp>
#include <pstl/execution>
Expand All @@ -8,6 +9,7 @@

#include "recursive_graph_bisection.hpp"
#include "util/progress.hpp"
#include "payload_vector.hpp"

using namespace pisa;
using iterator_type = std::vector<uint32_t>::iterator;
Expand Down Expand Up @@ -54,6 +56,8 @@ int main(int argc, char const *argv[])
std::string input_fwd;
std::string output_fwd;
std::string config_file;
std::optional<std::string> documents_filename;
std::optional<std::string> reordered_documents_filename;
size_t min_len = 0;
size_t depth = 0;
size_t threads = std::thread::hardware_concurrency();
Expand All @@ -65,6 +69,8 @@ int main(int argc, char const *argv[])
app.add_option("-o,--output", output_basename, "Output basename");
app.add_option("--store-fwdidx", output_fwd, "Output basename (forward index)");
app.add_option("--fwdidx", input_fwd, "Use this forward index");
auto docs_opt = app.add_option("--documents", documents_filename, "Documents lexicon");
app.add_option("--reordered-documents", reordered_documents_filename, "Reordered documents lexicon")->needs(docs_opt);
app.add_option("-m,--min-len", min_len, "Minimum list threshold");
auto optdepth =
app.add_option("-d,--depth", depth, "Recursion depth")->check(CLI::Range(1, 64));
Expand Down Expand Up @@ -116,6 +122,14 @@ int main(int argc, char const *argv[])
fwd.clear();
documents.clear();
reorder_inverted_index(input_basename, output_basename, mapping);
if(documents_filename) {
auto documents = Payload_Vector<>::from(*documents_filename);
std::vector<std::string> reordered_documents(documents.size());
for (size_t i = 0; i < documents.size(); ++i) {
reordered_documents[mapping[i]] = documents[i];
}
encode_payload_vector(reordered_documents.begin(), reordered_documents.end()).to_file(*reordered_documents_filename);
}
}
return 0;
}

0 comments on commit 5b4cacb

Please sign in to comment.