diff --git a/frozen/bits/pmh.h b/frozen/bits/pmh.h index 20fccae3..f2608126 100644 --- a/frozen/bits/pmh.h +++ b/frozen/bits/pmh.h @@ -24,12 +24,13 @@ #ifndef FROZEN_LETITGO_PMH_H #define FROZEN_LETITGO_PMH_H -#include "frozen/bits/algorithms.h" -#include "frozen/bits/basic_types.h" - #include +#include #include +#include "frozen/bits/algorithms.h" +#include "frozen/bits/basic_types.h" + namespace frozen { namespace bits { @@ -47,7 +48,8 @@ struct bucket_size_compare { // hash function. // pmh_buckets represents the initial placement into buckets. -template struct pmh_buckets { +template +struct pmh_buckets { // Step 0: Bucket max is 2 * sqrt M // TODO: Come up with justification for this, should it not be O(log M)? static constexpr auto bucket_max = 2 * (1u << (log(M) / 2)); @@ -135,14 +137,14 @@ constexpr bool all_different_from(cvector &data, T &a) { struct seed_or_index { using value_type = uint64_t; -private: + private: static constexpr value_type MINUS_ONE = (std::numeric_limits::max)(); static constexpr value_type HIGH_BIT = ~(MINUS_ONE >> 1); value_type value_ = 0; -public: + public: constexpr value_type value() const { return value_; } constexpr bool is_seed() const { return value_ & HIGH_BIT; } @@ -155,7 +157,8 @@ struct seed_or_index { }; // Represents the perfect hash function created by pmh algorithm -template struct pmh_tables { +template +struct pmh_tables { uint64_t first_seed_; carray first_table_; carray second_table_; @@ -175,7 +178,7 @@ template struct pmh_tables { first_table_[hasher(key, static_cast(first_seed_)) % M]; if (!d.is_seed()) { return static_cast(d.value()); - } // this is narrowing uint64 -> size_t but should be fine + } // this is narrowing uint64 -> size_t but should be fine else { return second_table_[hasher(key, static_cast(d.value())) % M]; @@ -196,7 +199,7 @@ pmh_tables constexpr make_pmh_tables(const carray &items, auto buckets = step_one.get_sorted_buckets(); // G becomes the first hash table in the resulting pmh function - carray G; // Default constructed to "index 0" + carray G; // Default constructed to "index 0" // H becomes the second hash table in the resulting pmh function constexpr std::size_t UNUSED = (std::numeric_limits::max)(); @@ -211,8 +214,8 @@ pmh_tables constexpr make_pmh_tables(const carray &items, // Store index to the (single) item in G // assert(bucket.hash == hash(key(items[bucket[0]]), step_one.seed) % M); G[bucket.hash] = {false, static_cast(bucket[0])}; - } else if (bsize > 1) { - + } + else if (bsize > 1) { // Repeatedly try different H of d until we find a hash function // that places all items in the bucket into free slots seed_or_index d{true, prg()}; @@ -235,8 +238,7 @@ pmh_tables constexpr make_pmh_tables(const carray &items, // Put successful seed in G, and put indices to items in their slots // assert(bucket.hash == hash(key(items[bucket[0]]), step_one.seed) % M); G[bucket.hash] = d; - for (std::size_t i = 0; i < bsize; ++i) - H[bucket_slots[i]] = bucket[i]; + for (std::size_t i = 0; i < bsize; ++i) H[bucket_slots[i]] = bucket[i]; } } @@ -251,8 +253,8 @@ pmh_tables constexpr make_pmh_tables(const carray &items, return {step_one.seed, G, H, hash}; } -} // namespace bits +} // namespace bits -} // namespace frozen +} // namespace frozen #endif diff --git a/iguana/pb_writer.hpp b/iguana/pb_writer.hpp index eac42401..3aa61303 100644 --- a/iguana/pb_writer.hpp +++ b/iguana/pb_writer.hpp @@ -232,6 +232,24 @@ IGUANA_INLINE constexpr std::string_view get_type_string() { } } } + else if constexpr (std::is_same_v) { + return "sint32"; + } + else if constexpr (std::is_same_v) { + return "sint64"; + } + else if constexpr (std::is_same_v) { + return "fixed32"; + } + else if constexpr (std::is_same_v) { + return "fixed64"; + } + else if constexpr (std::is_same_v) { + return "sfixed32"; + } + else if constexpr (std::is_same_v) { + return "sfixed64"; + } else if constexpr (std::is_same_v || std::is_same_v) { return "string";