[concurrency-interest] ConcurrentHashMap use of MAXIMUM_CAPACITY in Segment.rehash()

Rachel Suddeth programm_r at yahoo.com
Wed Jan 10 12:36:28 EST 2007


I am looking at the rehash() method in the Segment
inner class of ConcurrentHashMap. First thing it does
is test for maximum size:
---
   void rehash() {
       HashEntry<K,V>[] oldTable = table;
       int oldCapacity = oldTable.length;
       if (oldCapacity >= MAXIMUM_CAPACITY)
            return;
       ...
---

It seems odd to me that it's testing against the max
number of bins for the whole ConcurrentHashMap when
deciding to resize the segment table. (Is that not
what MAXIMUM_CAPACITY represents?) Initial size for
the segment table is (essentially)
initialCapacity/concurrencyLevel. I would have
expected the max for the segment to be calculated in a
similar way. I thought (maybe this is wrong?) that
certain bits of the Key's hash code were used to
determine the segment, and the others would determine
the bin within the segment, so that the full value of
an int would not be usable as an index into the
segment's table?

Am I missing something?


 
____________________________________________________________________________________
Any questions? Get answers on any topic at www.Answers.yahoo.com.  Try it now.


More information about the Concurrency-interest mailing list