Class PublisherReducers
java.lang.Object
org.infinispan.reactive.publisher.PublisherReducers
Static factory method class to provide various reducers and finalizers for use with distributed Publisher. Note
that these functions are all serializable by Infinispan assuming that any passed arguments are as well.
- Since:
- 10.0
- Author:
- wburns
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic final classstatic classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic classstatic classstatic classstatic final classstatic classstatic classstatic classstatic classstatic classstatic classstatic classPublisherReducers.ToArrayReducer<I extends E, E> -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> accumulate(BiConsumer<E, E> biConsumer) static Function<org.reactivestreams.Publisher<Long>, CompletionStage<Long>> add()static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<Boolean>> static Function<org.reactivestreams.Publisher<Boolean>, CompletionStage<Boolean>> and()static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<Boolean>> static <I,E> Function <org.reactivestreams.Publisher<I>, CompletionStage<E>> collect(Supplier<E> supplier, BiConsumer<E, ? super I> consumer) static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorFinalizer(Collector<?, E, ?> collector) A collector that is used for its combiner only.static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorFinalizer(SerializableSupplier<Collector<?, E, ?>> collectorSupplier) Used as an alternative tocollectorFinalizer(Collector)that allows for serializing a supplier that creates a collector on the remote nodes.static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorIdentityFinalizer(Collector<?, ?, E> collector) Provides a collector based publisher finalizer where the collector must have identity finish and thus the intermediate type is normally.static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorIdentityFinalizer(SerializableSupplier<Collector<?, ?, E>> collectorSupplier) Used as an alternative tocollectorReducer(Collector)that allows for serializing a supplier that creates a collector on the remote nodes.static <I,E> Function <org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorIdentityReducer(Collector<? super I, ?, E> collectorSupplier) Used as an alternative tocollectorReducer(Collector)to simplify generics when a Collector doesn't define its intermediate type, such asCollectors.toList().static <I,E> Function <org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorIdentityReducer(SerializableSupplier<Collector<? super I, ?, E>> collectorSupplier) Used as an alternative tocollectorReducer(Collector)that allows for serializing a supplier that creates a collector on the remote nodes.static <I,E> Function <org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorReducer(Collector<? super I, E, ?> collector) A collector that is used only for its supplier and accumulator.static <I,E> Function <org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorReducer(SerializableSupplier<Collector<? super I, E, ?>> collectorSupplier) Use this when a collector cannot be serialized forcollectorReducer(Collector).static Function<org.reactivestreams.Publisher<?>, CompletionStage<Long>> count()static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> max(Comparator<? super E> comparator) static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> min(Comparator<? super E> comparator) static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<Boolean>> static Function<org.reactivestreams.Publisher<Boolean>, CompletionStage<Boolean>> or()static <I,E> Function <org.reactivestreams.Publisher<I>, CompletionStage<E>> reduce(E identity, BiFunction<E, ? super I, E> biFunction) Provides a reduction where the initial value must be the identity value that is not modified via the provided biFunction.static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> reduce(BinaryOperator<E> operator) static <I,E> Function <org.reactivestreams.Publisher<I>, CompletionStage<E>> reduceWith(Callable<? extends E> initialSupplier, BiFunction<E, ? super I, E> biFunction) static <E> Function<org.reactivestreams.Publisher<E[]>, CompletionStage<E[]>> static <E> Function<org.reactivestreams.Publisher<E[]>, CompletionStage<E[]>> toArrayFinalizer(IntFunction<E[]> generator) static <I> Function<org.reactivestreams.Publisher<I>, CompletionStage<Object[]>> static <I extends E, E>
Function<org.reactivestreams.Publisher<I>, CompletionStage<E[]>> toArrayReducer(IntFunction<E[]> generator)
-
Method Details
-
and
-
allMatch
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<Boolean>> allMatch(Predicate<? super E> predicate) -
anyMatch
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<Boolean>> anyMatch(Predicate<? super E> predicate) -
collect
public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> collect(Supplier<E> supplier, BiConsumer<E, ? super I> consumer) -
collectorReducer
public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorReducer(Collector<? super I, E, ?> collector) A collector that is used only for its supplier and accumulator. The combiner and finisher are not used. If used in a distributed publisher the supplier will be invoked on each node first and then the accumulator is invoked for the data in that node. -
collectorReducer
public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorReducer(SerializableSupplier<Collector<? super I, E, ?>> collectorSupplier) Use this when a collector cannot be serialized forcollectorReducer(Collector). -
collectorIdentityReducer
public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorIdentityReducer(Collector<? super I, ?, E> collectorSupplier) Used as an alternative tocollectorReducer(Collector)to simplify generics when a Collector doesn't define its intermediate type, such asCollectors.toList(). -
collectorIdentityReducer
public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorIdentityReducer(SerializableSupplier<Collector<? super I, ?, E>> collectorSupplier) Used as an alternative tocollectorReducer(Collector)that allows for serializing a supplier that creates a collector on the remote nodes. Useful when a collector can't be serialized like the ones fromCollectorsclass. -
collectorFinalizer
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorFinalizer(Collector<?, E, ?> collector) A collector that is used for its combiner only. The supplier and accumulator are not used. It is used when combining results from multiple nodes, parallel publishers and when multiple segments are used. -
collectorFinalizer
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorFinalizer(SerializableSupplier<Collector<?, E, ?>> collectorSupplier) Used as an alternative tocollectorFinalizer(Collector)that allows for serializing a supplier that creates a collector on the remote nodes. Useful when a collector can't be serialized like the ones fromCollectorsclass. -
collectorIdentityFinalizer
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorIdentityFinalizer(Collector<?, ?, E> collector) Provides a collector based publisher finalizer where the collector must have identity finish and thus the intermediate type is normally. This method is here for typing purposes. not defined in theCollectorsclass methods. Note only the combiner is used and the finalizer is not actually used and thus why it must have identity finish. -
collectorIdentityFinalizer
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> collectorIdentityFinalizer(SerializableSupplier<Collector<?, ?, E>> collectorSupplier) Used as an alternative tocollectorReducer(Collector)that allows for serializing a supplier that creates a collector on the remote nodes. Useful when a collector can't be serialized like the ones fromCollectorsclass. -
accumulate
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> accumulate(BiConsumer<E, E> biConsumer) -
findFirst
-
max
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> max(Comparator<? super E> comparator) -
min
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> min(Comparator<? super E> comparator) -
noneMatch
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<Boolean>> noneMatch(Predicate<? super E> predicate) -
or
-
reduce
public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> reduce(E identity, BiFunction<E, ? super I, E> biFunction) Provides a reduction where the initial value must be the identity value that is not modified via the provided biFunction. Failure to do so will cause unexpected results.If the initial value needs to be modified, you should use
reduceWith(Callable, BiFunction)instead.- Type Parameters:
I- input typeE- output reduced type- Parameters:
identity- initial identity value to use (this value must not be modified by the provide biFunction)biFunction- biFunction used to reduce the values into a single one- Returns:
- function that will map a publisher of the input type to a completion stage of the output type
-
reduceWith
public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> reduceWith(Callable<? extends E> initialSupplier, BiFunction<E, ? super I, E> biFunction) -
reduce
public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> reduce(BinaryOperator<E> operator) -
count
-
add
-
toArrayReducer
public static <I> Function<org.reactivestreams.Publisher<I>, CompletionStage<Object[]>> toArrayReducer() -
toArrayReducer
public static <I extends E, E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E[]>> toArrayReducer(IntFunction<E[]> generator) -
toArrayFinalizer
public static <E> Function<org.reactivestreams.Publisher<E[]>, CompletionStage<E[]>> toArrayFinalizer() -
toArrayFinalizer
public static <E> Function<org.reactivestreams.Publisher<E[]>, CompletionStage<E[]>> toArrayFinalizer(IntFunction<E[]> generator)
-