Clojure map borders and consistency

I would like to know, given that Clojure uses a 32-bit hash for its implementation of the card, if the Clojure card has a 2 ^ 32-1 key limit (and if it doesn’t, how to do it manages conflicts), and if its hash implementation consistent . TIA!

+6
source share
1 answer

Clojure cards are a custom implementation that is constant and immutable (i.e., it does not use Java hash files, which would not provide sufficient performance when used in an immutable data structure).

It uses 32-bit hash codes, hence 2 ^ 32 possible hash codes . In case of collisions, keys and values ​​are stored in an array for each hash bucket, so it is possible to have more than 2 ^ 32 keys . See PersistentHashMap source - in particular, the internal HashCollisionNode class is used to store a bucket of keys / values ​​at a single hash code value.

Since the number of possible hash codes is fixed, consistent hashing does not matter - the key never needs to be reassigned.

See also:

+11
source

Source: https://habr.com/ru/post/918358/


All Articles