0

Is it a right approach to use JSON4S hashCode JValue method as a key to store json in key-value store? I am embarrassed about it's length and possible collisions.

Andrey Filyanin
  • 87
  • 1
  • 11

1 Answers1

0

I found a Birthday Paradox. Wiki page has a probability table wich demonstrates that with the hashCode size of a 32 bits you have a 50% chance to hit a collision if you have more than 77000 objects to hash. So in my case i nedd more than 500000 keys to store. So answer is "No" in my case, but depends on the final size of the key collection.

Andrey Filyanin
  • 87
  • 1
  • 11
  • Collision mostly depends from implementation of function under the hood, and 77000 is not critical threshold to collision. –  Jan 20 '17 at 13:54
  • It is a 50% chance for hit a collision, with 1.1 × 10⁵ it is a 75% chance, so with 500K keys it will tends to 100% chance. And only one collision in my case it's a big problem with 70M subscribers with links on the wrong data. – Andrey Filyanin Jan 20 '17 at 15:44
  • If you use `UUID` for 500000 keys, it will work fine, don't be afraid about collision with `UUID` –  Jan 20 '17 at 22:06