void mergeWith(GroupingListHit result) {
        ++groupingHitsMerged;
        if (documentDatabase == null) documentDatabase = result.getDocumentDatBase();
        if (query == null) query = result.getQuery();
        log.log(Level.FINE, () ->
                String.format("Merging hit #%d having %d groupings",
                        groupingHitsMerged, result.getGroupingList().size()));
        for (Grouping grouping : result.getGroupingList()) {
            groupings.merge(grouping.getId(), grouping, (existingGrouping, newGrouping) -> {
                existingGrouping.merge(newGrouping);
                return existingGrouping;
            });
        }
    }
Incrementally merges underlying {@link Grouping} instances from {@link GroupingListHit} hits.

@author bjorncs
container-search/src/main/java/com/yahoo/search/dispatch/GroupingResultAggregator.java