private static int writeHits(int i, Stream<Hit> hitStream, BufferedWriter writer) {
        try {
            List<Hit> hits = hitStream.toList();
            writer.append(Integer.toString(i))
                    .append(": ")
                    .append(hits.stream()
                            .map(hit -> String.format("(%d, 0x%x)", hit.getDocId(), hit.getSubquery()))
                            .collect(joining(", ", "[", "]")))
                    .append("\n\n");
            return hits.size();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
A test that runs outputs the hits for each query into result file.

@author bjorncs
predicate-search/src/main/java/com/yahoo/search/predicate/benchmarks/HitsVerificationBenchmark.java