Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I generate more mix hash seed? #245

Closed
stdpain opened this issue Jul 23, 2024 · 1 comment
Closed

how can I generate more mix hash seed? #245

stdpain opened this issue Jul 23, 2024 · 1 comment

Comments

@stdpain
Copy link
Contributor

stdpain commented Jul 23, 2024

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};
@greg7mdp
Copy link
Owner

greg7mdp commented Nov 2, 2024

Hi @stdpain, I'm not an expert in this. but usually these mix values are large prime numbers. There is a good explanation for the reason here

@greg7mdp greg7mdp closed this as completed Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants