in graphjet-core/src/main/java/com/twitter/graphjet/hashing/IntToIntPairConcurrentHashMap.java [295:324]
private void resize() {
// Keep the number of buckets to be power of 2 so that we can use bit-masks instead of mod
// The downside of that decision is that this can only grow by doubling
int newNumKeySlotsAllocated = numKeySlotsAllocated << 1;
BigIntArray newArray = new ShardedBigIntArray(
newNumKeySlotsAllocated * NUM_INTS_PER_KEY,
ShardedBigIntArray.PREFERRED_EDGES_PER_SHARD,
defaultReturnValue,
scopedStatsReceiver);
int bitMask = newNumKeySlotsAllocated - 1;
int maxNumKeysToStore = (int) (loadFactor * newNumKeySlotsAllocated);
ReaderAccessibleInfo newReaderAccessibleInfo =
new ReaderAccessibleInfo(newArray, bitMask, maxNumKeysToStore);
// now re-hash all the old entries in the new array
for (int i = 0; i < numKeySlotsAllocated * NUM_INTS_PER_KEY; i += NUM_INTS_PER_KEY) {
int key = readerAccessibleInfo.array.getEntry(i);
if (key != defaultReturnValue) {
put(key,
readerAccessibleInfo.array.getEntry(i + 1),
readerAccessibleInfo.array.getEntry(i + 2),
newReaderAccessibleInfo,
false);
}
}
numKeySlotsAllocated = newNumKeySlotsAllocated;
// creating a new object publishes it
readerAccessibleInfo = new ReaderAccessibleInfo(newArray, bitMask, maxNumKeysToStore);
}