Class PublisherReducers

java.lang.Object
org.infinispan.reactive.publisher.PublisherReducers

public class PublisherReducers extends Object
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
  • Method Details

    • and

      public static Function<org.reactivestreams.Publisher<Boolean>, CompletionStage<Boolean>> 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 for collectorReducer(Collector).
    • collectorIdentityReducer

      public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorIdentityReducer(Collector<? super I, ?, E> collectorSupplier)
      Used as an alternative to collectorReducer(Collector) to simplify generics when a Collector doesn't define its intermediate type, such as Collectors.toList().
    • collectorIdentityReducer

      public static <I,E> Function<org.reactivestreams.Publisher<I>, CompletionStage<E>> collectorIdentityReducer(SerializableSupplier<Collector<? super I, ?, E>> collectorSupplier)
      Used as an alternative to collectorReducer(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 from Collectors class.
    • 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 to collectorFinalizer(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 from Collectors class.
    • 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 the Collectors class 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 to collectorReducer(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 from Collectors class.
    • accumulate

      public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> accumulate(BiConsumer<E,E> biConsumer)
    • findFirst

      public static <E> Function<org.reactivestreams.Publisher<E>, CompletionStage<E>> 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

      public static Function<org.reactivestreams.Publisher<Boolean>, CompletionStage<Boolean>> 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 type
      E - 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

      public static Function<org.reactivestreams.Publisher<?>, CompletionStage<Long>> count()
    • add

      public static Function<org.reactivestreams.Publisher<Long>, CompletionStage<Long>> 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)