Interface IgniteReducer2<E1,​E2,​R>

  • Type Parameters:
    E1 - Type of the first free variable, i.e. the element the closure is called on.
    E2 - Type of the second free variable, i.e. the element the closure is called on.
    R - Type of the closure's return value.
    All Superinterfaces:
    IgniteOutClosure<R>, Serializable
    All Known Subinterfaces:
    R2<E1,​E2,​R>
    All Known Implementing Classes:
    IgniteReducer2X, RX2

    public interface IgniteReducer2<E1,​E2,​R>
    extends IgniteOutClosure<R>
    Defines generic for-all or reduce type of closure. Unlike for-each type of closure that returns optional value on each execution of the closure - the reducer returns a single value for one or more collected values.

    Closures are a first-class functions that are defined with (or closed over) their free variables that are bound to the closure scope at execution. Since Java 6 doesn't provide a language construct for first-class function the closures are implemented as abstract classes.

    Thread Safety

    Note that this interface does not impose or assume any specific thread-safety by its implementations. Each implementation can elect what type of thread-safety it provides, if any.
    • Method Detail

      • collect

        boolean collect​(@Nullable
                        E1 e1,
                        @Nullable
                        E2 e2)
        Collects given values. All values will be reduced by IgniteOutClosure.apply() method.

        The nulls could be passed if the data being collected is indeed null. If execution failed this method will not be called.

        Parameters:
        e1 - First bound free variable, i.e. the element the closure is called on.
        e2 - Second bound free variable, i.e. the element the closure is called on.
        Returns:
        true to continue collecting, false to instruct caller to stop collecting and call IgniteOutClosure.apply() method.