private void handleSearchResult(SearchResult result) {
        log.log(Level.FINE, () -> "Got SearchResult with " + result.getTotalHitCount() +
                                  " in total and " + result.getHitCount() +
                                  " hits in real for query with selection " + params.getDocumentSelection());

        List<SearchResult.Hit> newHits = new ArrayList<>(result.getHitCount());
        for (int i = 0; i < result.getHitCount(); i++)
            newHits.add(result.getHit(i));

        synchronized (this) {
            totalHitCount += result.getTotalHitCount();
            hits = ListMerger.mergeIntoArrayList(hits, newHits, query.getOffset() + query.getHits());
            var newErrors = result.getErrors();
            for (var error : newErrors) {
                errors.add(error);
            }
        }

        Map<Integer, byte[]> newGroupingMap = result.getGroupingList();
        mergeGroupingMaps(newGroupingMap);
    }
A visitor data handler that performs a query in a content cluster with the
searchvisitor visitor plugin. It collects and merges hits (sorted
descending on rank), summaries (sorted on document id), and
groupings. The resulting data can be fetched when the query has
completed.

@author Ulf Carlin
container-search/src/main/java/com/yahoo/vespa/streamingvisitors/StreamingVisitor.java