private void rehash(int newSize) {
        Object[] prevElements = elements;
        elements = new Object[newSize];
        List<Object> ready = new ArrayList<>();
        for (int slot = 0; slot < prevElements.length; slot++) {
            unpackSlot(ready, prevElements, slot);
            for (Object object : ready) {
                int newSlot = findSlot(object, elements.length);
                Object cur = elements[newSlot];
                if (cur == null) {
                    elements[newSlot] = object;
                } else if (cur instanceof Object[]) {
                    Object[] curArray = (Object[]) cur;
                    Object[] newArray = new Object[curArray.length + 1];
                    System.arraycopy(curArray, 0, newArray, 0, curArray.length);
                    newArray[curArray.length] = object;
                    elements[newSlot] = newArray;
                } else {
                    elements[newSlot] = new Object[]{cur, object};
                }
            }
            ready.clear();
        }
    }
Expand the hash table to a new size.  Existing elements will be copied to new slots.
server-common/src/main/java/org/apache/kafka/timeline/BaseHashTable.java