presto-main/src/main/java/io/prestosql/operator/WindowInfo.java/DriverWindowInfoBuilder/build
class DriverWindowInfoBuilder:        public DriverWindowInfo build()
        {
            if (currentIndexInfoBuilder != null) {
                Optional<IndexInfo> indexInfo = currentIndexInfoBuilder.build();
                indexInfo.ifPresent(indexInfosBuilder::add);
                currentIndexInfoBuilder = null;
            }

            List<IndexInfo> indexInfos = indexInfosBuilder.build();
            if (indexInfos.size() == 0) {
                return new DriverWindowInfo(0.0, 0.0, 0.0, 0, 0, 0);
            }
            long totalRowsCount = indexInfos.stream()
                    .mapToLong(IndexInfo::getTotalRowsCount)
                    .sum();
            double averageIndexPositions = totalRowsCount / indexInfos.size();
            double squaredDifferencesPositionsOfIndex = indexInfos.stream()
                    .mapToDouble(index -> Math.pow(index.getTotalRowsCount() - averageIndexPositions, 2))
                    .sum();
            double averageIndexSize = indexInfos.stream()
                    .mapToLong(IndexInfo::getSizeInBytes)
                    .average()
                    .getAsDouble();
            double squaredDifferencesSizeOfIndex = indexInfos.stream()
                    .mapToDouble(index -> Math.pow(index.getSizeInBytes() - averageIndexSize, 2))
                    .sum();
            double squaredDifferencesSizeInPartition = indexInfos.stream()
                    .mapToDouble(IndexInfo::getSumSquaredDifferencesSizeInPartition)
                    .sum();

            long totalPartitionsCount = indexInfos.stream()
                    .mapToLong(IndexInfo::getNumberOfPartitions)
                    .sum();

            return new DriverWindowInfo(squaredDifferencesPositionsOfIndex,
                    squaredDifferencesSizeOfIndex,
                    squaredDifferencesSizeInPartition,
                    totalPartitionsCount,
                    totalRowsCount,
                    indexInfos.size());
        }