public Histogram create(final Collection<S> executionStats) {

        int numTotalStats = executionStats.size();

        Map<T, Collection<S>> separatedInBins = new LinkedHashMap<>();
        availableBins.forEach(p -> separatedInBins.put(p, new LinkedList<>()));
        Collection<S> overBiggestBin = new LinkedList<>();
        executionStats.forEach(queryExecutionStats -> {
            final Optional<T> chosenBin = binChooser.chooseBin(availableBins, queryExecutionStats);
            chosenBin.ifPresentOrElse(
                    per -> separatedInBins.get(per).add(queryExecutionStats),
                    () -> overBiggestBin.add(queryExecutionStats)
                    );
                }
        );

        final List<MultiValueBin<NamedBinDefinition>> bins = separatedInBins.entrySet().stream()
                .map(entry -> entryToBin(entry.getKey().toString(), entry.getValue(), numTotalStats))
                .collect(Collectors.toCollection(ArrayList::new));
        bins.add(entryToBin(OUTSIDE_AVAILABLE_BINS_BIN_NAME, overBiggestBin, numTotalStats));
        return new Histogram(schema, bins);
    }
@Test
    void testCreatesProperHistogram() {
        final Collection<QueryExecutionStats> executionStats = List.of(
                getQueryExecutionStats(1, 1),
                getQueryExecutionStats(3, 1),
                getQueryExecutionStats(10, 3),
                getQueryExecutionStats(9, 3),
                getQueryExecutionStats(11, 3),
                getQueryExecutionStats(10, 3),
                getQueryExecutionStats(100, 70),
                getQueryExecutionStats(200, 71),
                getQueryExecutionStats(600, 72),
                getQueryExecutionStats(1234, 1111)
        );

        final Histogram histogram = toTest.create(executionStats);
        assertEquals(new Histogram(
                        List.of(TIMERANGE, AVG_FUNCTION_NAME, MAX_FUNCTION_NAME, PERCENT_FUNCTION_NAME),
                        List.of(
                                new MultiValueBin<>(new NamedBinDefinition("PT2H"), List.of(2L, 3L, 20L)),
                                new MultiValueBin<>(new NamedBinDefinition("PT4H"), List.of(10L, 11L, 40L)),
                                new MultiValueBin<>(new NamedBinDefinition("P2D"), List.of(0L, 0L, 0L)),
                                new MultiValueBin<>(new NamedBinDefinition("P4D"), List.of(300L, 600L, 30L)),
                                new MultiValueBin<>(new NamedBinDefinition(OUTSIDE_AVAILABLE_BINS_BIN_NAME), List.of(1234L, 1234L, 10L))
                        )
                ),
                histogram);
    }