I have a java applciation in which I want to generate long ids for strings (in order to store those strings in neo4j). In order to avoid data duplication, I would like to generate an id for each string stored in a long integer, which should be unique for each string. How can I do that ?
I have a java applciation in which I want to generate long ids for
Share
longhas 64 bits. AStringof length 9 has 72 bits. from pigeon hole principle – you cannot get a unique hashing for 9 chars long strings to along.If you still want a
longhash: You can just take two standard [different!] hash functions forString->int,hash1()andhash2()and calculate:hash(s) = 2^32* hash1(s) + hash2(s)