public int size2SizeIdx(int size) {
    int log2Size = log2((size << 1) - 1); // Calculate the approximate log2 value
    int shift = log2Size - log2MinSize - 1;

    // Calculate the size class group
    int group = shift << log2SizeClassGroup;
    int log2Delta = log2Size - 1 - log2SizeClassGroup;

    // Calculate the index within the size class group
    int mod = (size - 1) >> log2Delta & (1 << log2SizeClassGroup) - 1;
    return group + mod + 1;
  }
Returns the size class index for a given memory block size.

@param size The memory block size.
@return The corresponding size class index.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/binaryallocator/utils/SizeClasses.java