presto-main/src/main/java/io/prestosql/operator/aggregation/NumericHistogram.java/NumericHistogram/initializeQueue
class NumericHistogram:    private static PriorityQueue<Entry> initializeQueue(double[] values, double[] weights, int nextIndex)
    {
        checkArgument(nextIndex > 0, "nextIndex must be > 0");

        PriorityQueue<Entry> queue = new PriorityQueue<>(nextIndex);

        Entry right = new Entry(nextIndex - 1, values[nextIndex - 1], weights[nextIndex - 1], null);
        queue.add(right);
        for (int i = nextIndex - 2; i >= 0; i--) {
            Entry current = new Entry(i, values[i], weights[i], right);
            queue.add(current);
            right = current;
        }

        return queue;
    }