minor
This commit is contained in:
parent
49419bf6fc
commit
822de1093f
|
@ -13,14 +13,14 @@ namespace xcdat {
|
|||
using trie_7_type = trie<bc_vector_7>;
|
||||
using trie_8_type = trie<bc_vector_8>;
|
||||
|
||||
using flag_type = std::remove_const_t<decltype(trie_7_type::l1_bits)>;
|
||||
|
||||
template <class Trie>
|
||||
[[maybe_unused]] Trie mmap(const char* address) {
|
||||
mmap_visitor visitor(address);
|
||||
flag_type flag;
|
||||
|
||||
std::uint32_t flag;
|
||||
visitor.visit(flag);
|
||||
XCDAT_THROW_IF(flag != Trie::l1_bits, "The input index type is different.");
|
||||
|
||||
Trie idx;
|
||||
visitor.visit(idx);
|
||||
return idx;
|
||||
|
@ -29,9 +29,11 @@ template <class Trie>
|
|||
template <class Trie>
|
||||
[[maybe_unused]] Trie load(std::string_view filepath) {
|
||||
load_visitor visitor(filepath);
|
||||
flag_type flag;
|
||||
|
||||
std::uint32_t flag;
|
||||
visitor.visit(flag);
|
||||
XCDAT_THROW_IF(flag != Trie::l1_bits, "The input index type is different.");
|
||||
|
||||
Trie idx;
|
||||
visitor.visit(idx);
|
||||
return idx;
|
||||
|
@ -40,7 +42,7 @@ template <class Trie>
|
|||
template <class Trie>
|
||||
[[maybe_unused]] std::uint64_t save(const Trie& idx, std::string_view filepath) {
|
||||
save_visitor visitor(filepath);
|
||||
visitor.visit(Trie::l1_bits); // flag
|
||||
visitor.visit(static_cast<std::uint32_t>(Trie::l1_bits)); // flag
|
||||
visitor.visit(const_cast<Trie&>(idx));
|
||||
return visitor.bytes();
|
||||
}
|
||||
|
@ -48,11 +50,20 @@ template <class Trie>
|
|||
template <class Trie>
|
||||
[[maybe_unused]] std::uint64_t memory_in_bytes(const Trie& idx) {
|
||||
size_visitor visitor;
|
||||
visitor.visit(Trie::l1_bits); // flag
|
||||
visitor.visit(static_cast<std::uint32_t>(Trie::l1_bits)); // flag
|
||||
visitor.visit(const_cast<Trie&>(idx));
|
||||
return visitor.bytes();
|
||||
}
|
||||
|
||||
[[maybe_unused]] std::uint32_t get_flag(std::string_view filepath) {
|
||||
std::ifstream ifs(filepath);
|
||||
XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file");
|
||||
|
||||
std::uint32_t flag;
|
||||
ifs.read(reinterpret_cast<char*>(&flag), sizeof(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
[[maybe_unused]] std::vector<std::string> load_strings(std::string_view filepath) {
|
||||
std::ifstream ifs(filepath);
|
||||
if (!ifs) {
|
||||
|
|
|
@ -10,14 +10,6 @@ cmd_line_parser::parser make_parser(int argc, char** argv) {
|
|||
return p;
|
||||
}
|
||||
|
||||
xcdat::flag_type get_flag(std::string_view filepath) {
|
||||
std::ifstream ifs(filepath);
|
||||
XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file");
|
||||
xcdat::flag_type flag;
|
||||
ifs.read(reinterpret_cast<char*>(&flag), sizeof(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
template <class Trie>
|
||||
int decode(const cmd_line_parser::parser& p) {
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
|
@ -45,7 +37,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
const auto flag = get_flag(input_idx);
|
||||
const auto flag = xcdat::get_flag(input_idx);
|
||||
|
||||
switch (flag) {
|
||||
case 7:
|
||||
|
|
|
@ -10,14 +10,6 @@ cmd_line_parser::parser make_parser(int argc, char** argv) {
|
|||
return p;
|
||||
}
|
||||
|
||||
xcdat::flag_type get_flag(std::string_view filepath) {
|
||||
std::ifstream ifs(filepath);
|
||||
XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file");
|
||||
xcdat::flag_type flag;
|
||||
ifs.read(reinterpret_cast<char*>(&flag), sizeof(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
template <class Trie>
|
||||
int enumerate(const cmd_line_parser::parser& p) {
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
|
@ -42,7 +34,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
const auto flag = get_flag(input_idx);
|
||||
const auto flag = xcdat::get_flag(input_idx);
|
||||
|
||||
switch (flag) {
|
||||
case 7:
|
||||
|
|
|
@ -10,14 +10,6 @@ cmd_line_parser::parser make_parser(int argc, char** argv) {
|
|||
return p;
|
||||
}
|
||||
|
||||
xcdat::flag_type get_flag(std::string_view filepath) {
|
||||
std::ifstream ifs(filepath);
|
||||
XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file");
|
||||
xcdat::flag_type flag;
|
||||
ifs.read(reinterpret_cast<char*>(&flag), sizeof(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
template <class Trie>
|
||||
int lookup(const cmd_line_parser::parser& p) {
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
|
@ -49,7 +41,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
const auto flag = get_flag(input_idx);
|
||||
const auto flag = xcdat::get_flag(input_idx);
|
||||
|
||||
switch (flag) {
|
||||
case 7:
|
||||
|
|
|
@ -11,14 +11,6 @@ cmd_line_parser::parser make_parser(int argc, char** argv) {
|
|||
return p;
|
||||
}
|
||||
|
||||
xcdat::flag_type get_flag(std::string_view filepath) {
|
||||
std::ifstream ifs(filepath);
|
||||
XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file");
|
||||
xcdat::flag_type flag;
|
||||
ifs.read(reinterpret_cast<char*>(&flag), sizeof(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
template <class Trie>
|
||||
int predictive_search(const cmd_line_parser::parser& p) {
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
|
@ -64,7 +56,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
const auto flag = get_flag(input_idx);
|
||||
const auto flag = xcdat::get_flag(input_idx);
|
||||
|
||||
switch (flag) {
|
||||
case 7:
|
||||
|
|
|
@ -10,14 +10,6 @@ cmd_line_parser::parser make_parser(int argc, char** argv) {
|
|||
return p;
|
||||
}
|
||||
|
||||
xcdat::flag_type get_flag(std::string_view filepath) {
|
||||
std::ifstream ifs(filepath);
|
||||
XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file");
|
||||
xcdat::flag_type flag;
|
||||
ifs.read(reinterpret_cast<char*>(&flag), sizeof(flag));
|
||||
return flag;
|
||||
}
|
||||
|
||||
template <class Trie>
|
||||
int prefix_search(const cmd_line_parser::parser& p) {
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
|
@ -62,7 +54,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
|
||||
const auto input_idx = p.get<std::string>("input_idx");
|
||||
const auto flag = get_flag(input_idx);
|
||||
const auto flag = xcdat::get_flag(input_idx);
|
||||
|
||||
switch (flag) {
|
||||
case 7:
|
||||
|
|
Loading…
Reference in a new issue