rename typeid

This commit is contained in:
Shunsuke Kanda 2021-07-08 22:53:29 +09:00
parent ebaa3a8518
commit 762622f653
2 changed files with 10 additions and 10 deletions

View file

@ -34,7 +34,7 @@ template <class Trie>
std::uint32_t type_id; std::uint32_t type_id;
visitor.visit(type_id); visitor.visit(type_id);
XCDAT_THROW_IF(type_id != Trie::l1_bits, "The input dictionary type is different."); XCDAT_THROW_IF(type_id != Trie::type_id, "The input dictionary type is different.");
Trie idx; Trie idx;
visitor.visit(idx); visitor.visit(idx);
@ -48,7 +48,7 @@ template <class Trie>
std::uint32_t type_id; std::uint32_t type_id;
visitor.visit(type_id); visitor.visit(type_id);
XCDAT_THROW_IF(type_id != Trie::l1_bits, "The input dictionary type is different."); XCDAT_THROW_IF(type_id != Trie::type_id, "The input dictionary type is different.");
Trie idx; Trie idx;
visitor.visit(idx); visitor.visit(idx);
@ -60,7 +60,7 @@ template <class Trie>
template <class Trie> template <class Trie>
[[maybe_unused]] std::uint64_t save(const Trie& idx, const std::string& filepath) { [[maybe_unused]] std::uint64_t save(const Trie& idx, const std::string& filepath) {
save_visitor visitor(filepath); save_visitor visitor(filepath);
visitor.visit(static_cast<std::uint32_t>(Trie::l1_bits)); // identifier visitor.visit(static_cast<std::uint32_t>(Trie::type_id)); // identifier
visitor.visit(const_cast<Trie&>(idx)); visitor.visit(const_cast<Trie&>(idx));
return visitor.bytes(); return visitor.bytes();
} }
@ -69,20 +69,20 @@ template <class Trie>
template <class Trie> template <class Trie>
[[maybe_unused]] std::uint64_t memory_in_bytes(const Trie& idx) { [[maybe_unused]] std::uint64_t memory_in_bytes(const Trie& idx) {
size_visitor visitor; size_visitor visitor;
visitor.visit(static_cast<std::uint32_t>(Trie::l1_bits)); // identifier visitor.visit(static_cast<std::uint32_t>(Trie::type_id)); // identifier
visitor.visit(const_cast<Trie&>(idx)); visitor.visit(const_cast<Trie&>(idx));
return visitor.bytes(); return visitor.bytes();
} }
//! Get the identifier of the trie type embedded by the function 'save'. //! Get the identifier of the trie type embedded by the function 'save'.
//! The identifier corresponds to trie::l1_bits and will be used to detect the trie type. //! The identifier corresponds to trie::type_id and will be used to detect the trie type.
[[maybe_unused]] std::uint32_t get_type_id(const std::string& filepath) { [[maybe_unused]] std::uint32_t get_type_id(const std::string& filepath) {
std::ifstream ifs(filepath); std::ifstream ifs(filepath);
XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file"); XCDAT_THROW_IF(!ifs.good(), "Cannot open the input file");
std::uint32_t flag; std::uint32_t type_id;
ifs.read(reinterpret_cast<char*>(&flag), sizeof(flag)); ifs.read(reinterpret_cast<char*>(&type_id), sizeof(type_id));
return flag; return type_id;
} }
} // namespace xcdat } // namespace xcdat

View file

@ -17,8 +17,8 @@ class trie {
using trie_type = trie<BcVector>; using trie_type = trie<BcVector>;
using bc_vector_type = BcVector; using bc_vector_type = BcVector;
//! The identifier of BC vector. //! The type identifier.
static constexpr auto l1_bits = bc_vector_type::l1_bits; static constexpr std::uint32_t type_id = bc_vector_type::l1_bits;
private: private:
std::uint64_t m_num_keys = 0; std::uint64_t m_num_keys = 0;