greg7mdp / parallel-hashmap

A family of header-only, very fast and memory-friendly hashmap and btree containers.
https://greg7mdp.github.io/parallel-hashmap/
Apache License 2.0
2.47k stars 234 forks source link

how can I generate more mix hash seed? #245

Open stdpain opened 1 month ago

stdpain commented 1 month ago

phmap mix is a pretty good rehash function. In a multi-stage aggregation process I want to use different mix values. But I don't know how to generate a proper mix seed.

   template<>
    struct phmap_mix<8>
    {
        // Very fast mixing (similar to Abseil)
        inline size_t operator()(size_t a) const
        {
            static constexpr uint64_t k = 0xde5fb9d2630458e9ULL;
            // static constexpr uint64_t k = 0x7C9D0BF0567102A5ULL; // [greg] my own random prime
            uint64_t h;
            uint64_t l = umul128(a, k, &h);
            return static_cast<size_t>(h + l);
        }
    };

in absl

  static constexpr uint64_t kMul =
      sizeof(size_t) == 4 ? uint64_t{0xcc9e2d51}
                          : uint64_t{0x9ddfea08eb382d69};