presto-main/src/main/java/io/prestosql/operator/aggregation/NumericHistogram.java/NumericHistogram/compact
class NumericHistogram:    @VisibleForTesting
    void compact()
    {
        nextIndex = mergeSameBuckets(values, weights, nextIndex);

        if (nextIndex <= maxBuckets) {
            return;
        }

        // entries are guaranteed to be sorted as a side-effect of the call to mergeSameBuckets
        store(mergeBuckets(values, weights, nextIndex, maxBuckets));
    }