0

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;
rombi
  • 199
  • 3
  • 22

2 Answers2

3

The line

cout  << hash_otpt << endl;

is emitting the address of hash_otpt, not its contents.

Jeremy
  • 5,055
  • 1
  • 28
  • 44
0

It should be

cout << hash_otpt[0] << hash_otpt[1] << endl;

Basically the 128-bit hash is split and stored in two 64-bit unsigned integers (the MSBs in one and the LSBs in another). On combining them, you get the complete hash.