Java 8 is providing alternative hashing for String keys to improve performance when a large number of key hash code collisions are encountered. Can anybody explain what is that and how it will work?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
It should be noted that the shift to MurmurHash3 will not prevent DoS attacks: http://emboss.github.com/blog/2012/12/14/breaking-murmur-hash-flooding-dos-reloaded/
To bring more relevance to this question, the alternative hashing has been removed from JDK 8. Check out :
http://docs.oracle.com/javase/8/docs/technotes/guides/collections/changes8.html
http://openjdk.java.net/jeps/180
It is interesting to note that once the number of items in a hash bucket grows beyond a certain threshold, that bucket will switch from using a linked list of entries to a balanced tree.
The hash(Object key) function in the HashMap has been revised to follows with no special treatment to String objects:
From this email of
core-lib-devs@openjkd
:The revisions of the code: