processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/HashVectorGrouper.java
/**
   * Compute the largest possible table bucket count given a particular buffer capacity, bucket size, and initial
   * bucket count. Assumes that tables are grown by allocating new tables that are twice as large and then copying
   * into them.
   *
   * @param capacity   buffer capacity, in bytes
   * @param bucketSize bucket size, in bytes
   */
Compute the largest possible table bucket count given a particular buffer capacity, bucket size, and initial
bucket count. Assumes that tables are grown by allocating new tables that are twice as large and then copying
into them.

@param capacity   buffer capacity, in bytes
@param bucketSize bucket size, in bytes
Compute the largest possible table bucket count given a particular buffer capacity bucket size and initial bucket count . Assumes that tables are grown by allocating new tables that are twice as large and then copying into them . @param capacity buffer capacity in bytes @param bucketSize bucket size in bytes
private static int computeMaxNumBucketsAfterGrowth(final int capacity, final int bucketSize)
  {
       2^(x-1) < capacity / bucketSize / 3
     Or:
       2^x < capacity / bucketSize / 3 * 2
     All other smaller tables fit within the 2/3rds of the buffer preceding the penultimate table, and then the
     memory they used can be reclaimed for the final table.
    return HashTableUtils.previousPowerOfTwo(Math.min(capacity / bucketSize / 3 * 2, 1 << 30));
  }
private static int computeMaxNumBucketsAfterGrowth ( final int capacity , final int bucketSize ) { return HashTableUtils . previousPowerOfTwo ( Math . min ( capacity / bucketSize / 3 * 2 , 1 << 30 ) ) ; }
Compute the largest possible table bucket count given a particular buffer capacity, bucket size, and initial
 bucket count.
Compute the largest possible table bucket count given a particular buffer capacity bucket size and initial bucket count .
// Tables start at some size (see computeRoundedInitialNumBuckets) and grow by doubling. The penultimate table ends // at the end of the buffer, and then the final table starts at the beginning of the buffer. This means the largest // possible table size 2^x is the one where x is maximized subject to: // //   2^(x-1) < capacity / bucketSize / 3 // // Or: // //   2^x < capacity / bucketSize / 3 * 2 // // All other smaller tables fit within the 2/3rds of the buffer preceding the penultimate table, and then the // memory they used can be reclaimed for the final table.