Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3243470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:26:14+00:00 2026-05-17T18:26:14+00:00

I am looking at MurmurHash (sites.google.com/site/murmurhash/) I’m using it in a black box kind

  • 0

I am looking at MurmurHash (sites.google.com/site/murmurhash/)
I’m using it in a black box kind of a way and not trying to understand the maths at this stage.

However, I did have a little look at the code and got worried about how it seems to work…
Here’s the code:

uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed )
{
    const uint64_t m = 0xc6a4a7935bd1e995;
    const int r = 47;

    uint64_t h = seed ^ (len * m);

    const uint64_t * data = (const uint64_t *)key;
    const uint64_t * end = data + (len/8);

    while(data != end)
    {
        uint64_t k = *data++;

        k *= m; 
        k ^= k >> r; 
        k *= m; 

        h ^= k;
        h *= m; 
    }

    const unsigned char * data2 = (const unsigned char*)data;

    switch(len & 7)
    {
    case 7: h ^= uint64_t(data2[6]) << 48;
    case 6: h ^= uint64_t(data2[5]) << 40;
    case 5: h ^= uint64_t(data2[4]) << 32;
    case 4: h ^= uint64_t(data2[3]) << 24;
    case 3: h ^= uint64_t(data2[2]) << 16;
    case 2: h ^= uint64_t(data2[1]) << 8;
    case 1: h ^= uint64_t(data2[0]);
            h *= m;
    };

    h ^= h >> r;
    h *= m;
    h ^= h >> r;

    return h;
} 

Note this is the 64bit version for 64bit machines.
My problem is that I don’t understand how it steps through the key you send it. If I for example send it a pointer to a string of characters “ABC”. I can see that I would send it a pointer to the first character “A” and a length of 3.

My limited C++ knowledge tells me that it creates a pointer ‘data’ that points to the same location as the incoming pointer. But then in it calculates the end of the key by taking ‘data’ and adding to it the length of the string divided by 8.
So if the key were less than 8 the while loop wouldn’t get triggered and none of the first bit of maths stuff would get done.
Does anyone know why it divides by 8?

Is it because the first maths bit only is only meant to happen to keys 8 characters and over (if so why)?

Thanks in advance.
C

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:26:15+00:00Added an answer on May 17, 2026 at 6:26 pm

    The algorithm processes the data passed 8 bytes at a time (uint64_t is 8 bytes).
    The first loop will combine all set of 8 bytes to make a single key of 8 bytes.
    Then the switch will use the remaining bytes (all 3 bytes in your example passing “ABC”) and processes it to take them into account in the final result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking at the Slickgrid examples and using Google Chrome, I'm setting a breakpoint on
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
Looking to do a bit of refactoring... Using NHibernate I have this query currently
Looking at the Ehcahce implementation of net.sf.cache.JS107, I am trying to achieve the following
Looking for a way to get path of file (and then process it in
Looking for some help on my AJAX/jQuery implementation. I am trying to load some
Looking for a better way of extracting a number from the last line in
looking for some advice on what is the best way to deliver an HTML/CSS
Looking at the output of this particular method is confusing to me. I'm trying
Looking for a way to capture user password in case of Tomcat form-based authentication

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.