### Question:
DistributionBucket { public int getBucketIndex(long value) { int low = 0; int high = buckets.length - 1; long minVal = buckets[low]; long maxVal = buckets[high]; if (value >= maxVal) { return high; } if (value < minVal) { return high + 1; } while (low < high) { int mid = (low + high) >>> 1; long midVal = buckets[mid]; long nextToMidVal = buckets[mid + 1]; if (midVal <= value && value < nextToMidVal) { return mid; } else if (value < midVal) { high = mid - 1; } else { low = mid + 1; } } return low; } DistributionBucket(final long[] buckets);  DistributionBucket(final long[] buckets, final NameSpec nameSpec); int getCount(); int getBucketIndex(long value); String[] getBucketNames();  }### Answer:
@Test void testGetIndex() { DistributionBucket bucket = new DistributionBucket(new long[]{0, 10, 50, 100, 1000}); assertEquals(0, bucket.getBucketIndex(0)); assertEquals(0, bucket.getBucketIndex(1)); assertEquals(1, bucket.getBucketIndex(10)); assertEquals(2, bucket.getBucketIndex(50)); assertEquals(3, bucket.getBucketIndex(100)); assertEquals(4, bucket.getBucketIndex(1000)); assertEquals(4, bucket.getBucketIndex(1001)); assertEquals(4, bucket.getBucketIndex(1000000)); assertEquals(5, bucket.getBucketIndex(-10000)); assertEquals(5, bucket.getBucketIndex(-1)); }