presto-main/src/main/java/io/prestosql/sql/planner/planprinter/WindowOperatorStats.java/WindowOperatorStats/create
class WindowOperatorStats:    public static WindowOperatorStats create(WindowInfo info)
    {
        int activeDrivers = 0;
        int totalDrivers = 0;

        double partitionRowsSumSquaredDiffs = 0.0;
        double positionsInIndexesSumSquaredDiffs = 0.0;
        double sizeOfIndexesSumSquaredDiffs = 0.0;
        double indexCountPerDriverSumSquaredDiffs = 0.0;
        double rowCountPerDriverSumSquaredDiffs = 0.0;
        long totalRowCount = 0;
        long totalIndexesCount = 0;
        long totalPartitionsCount = 0;

        double averageNumberOfIndexes = info.getWindowInfos().stream()
                .filter(WindowOperatorStats::isMeaningful)
                .mapToLong(DriverWindowInfo::getNumberOfIndexes)
                .average()
                .orElse(Double.NaN);

        double averageNumberOfRows = info.getWindowInfos().stream()
                .filter(WindowOperatorStats::isMeaningful)
                .mapToLong(DriverWindowInfo::getTotalRowsCount)
                .average()
                .orElse(Double.NaN);

        for (DriverWindowInfo driverWindowInfo : info.getWindowInfos()) {
            long driverTotalRowsCount = driverWindowInfo.getTotalRowsCount();
            totalDrivers++;
            if (driverTotalRowsCount > 0) {
                long numberOfIndexes = driverWindowInfo.getNumberOfIndexes();

                partitionRowsSumSquaredDiffs += driverWindowInfo.getSumSquaredDifferencesSizeInPartition();
                totalPartitionsCount += driverWindowInfo.getTotalPartitionsCount();

                totalRowCount += driverWindowInfo.getTotalRowsCount();

                positionsInIndexesSumSquaredDiffs += driverWindowInfo.getSumSquaredDifferencesPositionsOfIndex();
                sizeOfIndexesSumSquaredDiffs += driverWindowInfo.getSumSquaredDifferencesSizeOfIndex();
                totalIndexesCount += numberOfIndexes;

                indexCountPerDriverSumSquaredDiffs += (Math.pow(numberOfIndexes - averageNumberOfIndexes, 2));
                rowCountPerDriverSumSquaredDiffs += (Math.pow(driverTotalRowsCount - averageNumberOfRows, 2));
                activeDrivers++;
            }
        }

        return new WindowOperatorStats(partitionRowsSumSquaredDiffs,
                positionsInIndexesSumSquaredDiffs,
                sizeOfIndexesSumSquaredDiffs,
                indexCountPerDriverSumSquaredDiffs,
                rowCountPerDriverSumSquaredDiffs,
                totalRowCount,
                totalIndexesCount,
                totalPartitionsCount,
                activeDrivers,
                totalDrivers);
    }