Package com.gengoai.stream
Interface MAccumulator<IN,OUT>
-
- Type Parameters:
IN
- the type parameter for what is being accumulatedOUT
- the type parameter for the result of the accumulation
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
MCounterAccumulator<T>
,MDoubleAccumulator
,MLongAccumulator
,MMapAccumulator<K,V>
,MMultiCounterAccumulator<K1,K2>
,MStatisticsAccumulator
- All Known Implementing Classes:
LocalMAccumulator
,LocalMCounterAccumulator
,LocalMDoubleAccumulator
,LocalMListAccumulator
,LocalMLongAccumulator
,LocalMMapAccumulator
,LocalMMultiCounterAccumulator
,LocalMSetAccumulator
,LocalMStatisticsAccumulator
,SparkMAccumulator
,SparkMCounterAccumulator
,SparkMDoubleAccumulator
,SparkMLongAccumulator
,SparkMMapAccumulator
,SparkMMultiCounterAccumulator
,SparkMStatisticsAccumulator
public interface MAccumulator<IN,OUT> extends Serializable
Base interface for accumulators that can work across local and distributed streams.
- Author:
- David B. Bracewell
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
add(IN in)
Adds an item to the accumulatorboolean
isZero()
Determines if the accumulator is a zero valuevoid
merge(MAccumulator<IN,OUT> other)
Merges another accumulator with this oneOptional<String>
name()
The name of the accumulatorvoid
register()
Registers the accumulator.default void
report(SerializablePredicate<? super OUT> when, Consumer<OUT> message)
Reports the given message when the given predicate evaluates to true.void
reset()
Resets the accumulator to its zero-value.OUT
value()
The value of the accumulator.
-
-
-
Method Detail
-
add
void add(IN in)
Adds an item to the accumulator- Parameters:
in
- the item to add
-
merge
void merge(MAccumulator<IN,OUT> other)
Merges another accumulator with this one- Parameters:
other
- the other accumulator to merge- Throws:
NullPointerException
- if the other accumulator is nullIllegalArgumentException
- if the other accumulator cannot be merged with this one
-
name
Optional<String> name()
The name of the accumulator- Returns:
- the optional name of the accumulator
-
reset
void reset()
Resets the accumulator to its zero-value.
-
value
OUT value()
The value of the accumulator.- Returns:
- the result of the accumulator
-
isZero
boolean isZero()
Determines if the accumulator is a zero value- Returns:
- True if the accumulator is in a zero state
-
register
void register()
Registers the accumulator.
-
report
default void report(SerializablePredicate<? super OUT> when, Consumer<OUT> message)
Reports the given message when the given predicate evaluates to true.- Parameters:
when
- the predicate controlling when the message should be performedmessage
- a consumer processing the current value of the accumulator
-
-