c++11hashmurmurhash

C++ MurmurHash3 returning same value for different key


I am confused with how should i call MurmurHash3_x86_128() when i have lot of key value. The murmurhash3 code can be found https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp. Method definition is given below.

void MurmurHash3_x86_128 ( const void * key, const int len,
                   uint32_t seed, void * out )

I am passing different key value using a for loop as shown below but still the hash value return is same. If i am removing for loop and passing individual key value then the value is different. What am i doing wrong ?

int main()
{
uint64_t seed = 100;
vector <string> ex;
ex.push_back("TAA");
ex.push_back("ATT");

for(int i=0; i < ex.size(); i++)
{

uint64_t hash_otpt[2]= {};

cout<< hash_otpt << "\t" << endl;
const char *key = ex[i].c_str();
cout << key << endl;
MurmurHash3_x64_128(key, strlen(key), seed, hash_otpt); // 0xb6d99cf8
cout  << hash_otpt << endl;


}

return 0;

Solution

  • The line

    cout  << hash_otpt << endl;
    

    is emitting the address of hash_otpt, not its contents.