processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/HashVectorGrouper.java
/**
   * Compute the initial table bucket count given a particular buffer capacity, bucket size, and user-configured
   * initial bucket count.
   *
   * @param capacity                    buffer capacity, in bytes
   * @param bucketSize                  bucket size, in bytes
   * @param configuredInitialNumBuckets user-configured initial bucket count
   */
Compute the initial table bucket count given a particular buffer capacity, bucket size, and user-configured
initial bucket count.

@param capacity                    buffer capacity, in bytes
@param bucketSize                  bucket size, in bytes
@param configuredInitialNumBuckets user-configured initial bucket count
Compute the initial table bucket count given a particular buffer capacity bucket size and user - configured initial bucket count . @param capacity buffer capacity in bytes @param bucketSize bucket size in bytes @param configuredInitialNumBuckets user - configured initial bucket count
private static int computeRoundedInitialNumBuckets(
      final int capacity,
      final int bucketSize,
      final int configuredInitialNumBuckets
  )
  {
    final int initialNumBucketsRoundedUp = (int) Math.min(
        1 << 30,
        HashCommon.nextPowerOfTwo((long) configuredInitialNumBuckets)
    );
    if (initialNumBucketsRoundedUp < computeMaxNumBucketsAfterGrowth(capacity, bucketSize)) {
      return initialNumBucketsRoundedUp;
    } else {
      return HashTableUtils.previousPowerOfTwo(Math.min(capacity / bucketSize, 1 << 30));
    }
  }
private static int computeRoundedInitialNumBuckets ( final int capacity , final int bucketSize , final int configuredInitialNumBuckets ) { final int initialNumBucketsRoundedUp = ( int ) Math . min ( 1 << 30 , HashCommon . nextPowerOfTwo ( ( long ) configuredInitialNumBuckets ) ) ; if ( initialNumBucketsRoundedUp < computeMaxNumBucketsAfterGrowth ( capacity , bucketSize ) ) { return initialNumBucketsRoundedUp ; } else { return HashTableUtils . previousPowerOfTwo ( Math . min ( capacity / bucketSize , 1 << 30 ) ) ; } }
Compute the initial table bucket count given a particular buffer capacity, bucket size, and user-configured
 initial bucket count.
Compute the initial table bucket count given a particular buffer capacity bucket size and user - configured initial bucket count .
// Special case: initialNumBucketsRoundedUp is equal to or higher than max capacity of a growable table; start out // at max size the buffer will hold. Note that this allows the table to be larger than it could ever be as a // result of growing, proving that biting off as much as you can chew is not always a bad strategy. (Why don't // we always do this? Because clearing a big table is expensive.)