Example usage for java.util.stream Collector combiner

List of usage examples for java.util.stream Collector combiner

Introduction

In this page you can find the example usage for java.util.stream Collector combiner.

Prototype

BinaryOperator<A> combiner();

Source Link

Document

A function that accepts two partial results and merges them.

Usage

From source file:org.briljantframework.data.Collectors.java

public static <T, A, R, F> Collector<T, ?, F> withFinisher(Collector<T, A, R> collector,
        Function<R, F> finisher) {
    Function<A, R> f = collector.finisher();

    Set<Collector.Characteristics> characteristics = collector.characteristics();
    Collector.Characteristics[] empty = new Collector.Characteristics[characteristics.size()];
    return Collector.of(collector.supplier(), collector.accumulator(), collector.combiner(),
            f.andThen(finisher), characteristics.toArray(empty));
}

From source file:org.trellisldp.api.TrellisUtilsTest.java

@Test
public void testDatasetCombiner() {
    final Set<Quad> quads1 = generate(() -> rdf.createQuad(getIRI(), getIRI(), getIRI(), getIRI())).parallel()
            .limit(size).collect(toSet());
    final Set<Quad> quads2 = generate(() -> rdf.createQuad(getIRI(), getIRI(), getIRI(), getIRI())).parallel()
            .limit(size).collect(toSet());

    final Collector<Quad, Set<Quad>, Dataset> collector = toDataset().concurrent();
    assertEquals(quads1.size() + quads2.size(), collector.combiner().apply(quads1, quads2).size(),
            "Dataset combiner produces the wrong number of quads!");
}