/** * Generates and concatenates Publishers on each 'rail', signalling errors immediately * and generating 2 publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher source and the * inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ public final <R> ParallelFlux<R> concatMap(Function<? super T, ? extends Publisher<? extends R>> mapper) { return concatMap(mapper, 2, ErrorMode.IMMEDIATE); }
/** * Generates and concatenates Publishers on each 'rail', delaying errors * and generating 2 publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * source and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ public final <R> ParallelFlux<R> concatMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper) { return concatMap(mapper, 2, ErrorMode.END); }
/** * Generates and concatenates Publishers on each 'rail', delaying errors * and using the given prefetch amount for generating Publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * @param prefetch the number of items to prefetch from each inner Publisher * source and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ final <R> ParallelFlux<R> concatMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper, int prefetch) { return concatMap(mapper, prefetch, ErrorMode.END); }
/** * Generates and concatenates Publishers on each 'rail', signalling errors immediately * and using the given prefetch amount for generating Publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * @param prefetch the number of items to prefetch from each inner Publisher source * and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ public final <R> ParallelFlux<R> concatMap(Function<? super T, ? extends Publisher<? extends R>> mapper, int prefetch) { return concatMap(mapper, prefetch, ErrorMode.IMMEDIATE); }
/** * Generates and concatenates Publishers on each 'rail', delaying errors * and using the given prefetch amount for generating Publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * @param delayUntilEnd true if delayed until all sources are concatenated * @param prefetch the number of items to prefetch from each inner Publisher * source and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ final <R> ParallelFlux<R> concatMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper, boolean delayUntilEnd, int prefetch) { return concatMap(mapper, prefetch, delayUntilEnd ? ErrorMode.END: ErrorMode.BOUNDARY); }
@Test public void testConcatMapPrefetch() { ParallelFlux<Integer> pf = ParallelFlux.from(Flux.range(1, 4), 2) .concatMap(i -> Flux.just(i, 100 * i), 4); assertThat(pf.getPrefetch()).isEqualTo(4); StepVerifier.create(pf) .expectNext(1, 100, 2, 200, 3, 300, 4, 400) .verifyComplete(); }
@Test public void concatMapUnordered() { AssertSubscriber<Integer> ts = AssertSubscriber.create(); Flux.range(1, 5) .parallel() .concatMap(v -> Flux.range(v * 10 + 1, 3)) .sequential() .subscribe(ts); ts.assertValues(11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43, 51, 52, 53) .assertNoError() .assertComplete(); }
/** * Generates and concatenates Publishers on each 'rail', signalling errors immediately * and generating 2 publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher source and the * inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ public final <R> ParallelFlux<R> concatMap(Function<? super T, ? extends Publisher<? extends R>> mapper) { return concatMap(mapper, 2, ErrorMode.IMMEDIATE); }
/** * Generates and concatenates Publishers on each 'rail', delaying errors * and using the given prefetch amount for generating Publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * @param prefetch the number of items to prefetch from each inner Publisher * source and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ final <R> ParallelFlux<R> concatMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper, int prefetch) { return concatMap(mapper, prefetch, ErrorMode.END); }
/** * Generates and concatenates Publishers on each 'rail', delaying errors * and generating 2 publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * source and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ public final <R> ParallelFlux<R> concatMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper) { return concatMap(mapper, 2, ErrorMode.END); }
/** * Generates and concatenates Publishers on each 'rail', signalling errors immediately * and using the given prefetch amount for generating Publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * @param prefetch the number of items to prefetch from each inner Publisher source * and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ public final <R> ParallelFlux<R> concatMap(Function<? super T, ? extends Publisher<? extends R>> mapper, int prefetch) { return concatMap(mapper, prefetch, ErrorMode.IMMEDIATE); }
/** * Generates and concatenates Publishers on each 'rail', delaying errors * and using the given prefetch amount for generating Publishers upfront. * * @param <R> the result type * @param mapper the function to map each rail's value into a Publisher * @param delayUntilEnd true if delayed until all sources are concatenated * @param prefetch the number of items to prefetch from each inner Publisher * source and the inner Publishers (immediate, boundary, end) * * @return the new {@link ParallelFlux} instance */ final <R> ParallelFlux<R> concatMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper, boolean delayUntilEnd, int prefetch) { return concatMap(mapper, prefetch, delayUntilEnd ? ErrorMode.END: ErrorMode.BOUNDARY); }