Package com.gengoai.stream.local
Class LocalMCounterAccumulator<IN>
- java.lang.Object
-
- com.gengoai.stream.local.LocalMAccumulator<IN,Counter<IN>>
-
- com.gengoai.stream.local.LocalMCounterAccumulator<IN>
-
- Type Parameters:
IN
- the component type parameter of the counter
- All Implemented Interfaces:
Copyable<LocalMAccumulator<IN,Counter<IN>>>
,MAccumulator<IN,Counter<IN>>
,MCounterAccumulator<IN>
,Serializable
public class LocalMCounterAccumulator<IN> extends LocalMAccumulator<IN,Counter<IN>> implements MCounterAccumulator<IN>
An implementation of a
MCounterAccumulator
for local streams- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LocalMCounterAccumulator(String name)
Instantiates a new LocalMCounterAccumulator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(IN in)
Adds an item to the accumulatorLocalMAccumulator<IN,Counter<IN>>
copy()
Makes a copy of this object.void
increment(IN item, double amount)
Increments the given item by the given amount.boolean
isZero()
Determines if the accumulator is a zero valuevoid
merge(Counter<? extends IN> counter)
Merges the given counter with this accumulatorvoid
merge(MAccumulator<IN,Counter<IN>> other)
Merges another accumulator with this onevoid
reset()
Resets the accumulator to its zero-value.Counter<IN>
value()
The value of the accumulator.-
Methods inherited from class com.gengoai.stream.local.LocalMAccumulator
name, register, report
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.gengoai.stream.MAccumulator
name, register, report
-
-
-
-
Constructor Detail
-
LocalMCounterAccumulator
public LocalMCounterAccumulator(String name)
Instantiates a new LocalMCounterAccumulator.- Parameters:
name
- the name of the accumulator
-
-
Method Detail
-
add
public void add(IN in)
Description copied from interface:MAccumulator
Adds an item to the accumulator- Specified by:
add
in interfaceMAccumulator<IN,Counter<IN>>
- Parameters:
in
- the item to add
-
merge
public void merge(MAccumulator<IN,Counter<IN>> other)
Description copied from interface:MAccumulator
Merges another accumulator with this one- Specified by:
merge
in interfaceMAccumulator<IN,Counter<IN>>
- Parameters:
other
- the other accumulator to merge
-
reset
public void reset()
Description copied from interface:MAccumulator
Resets the accumulator to its zero-value.- Specified by:
reset
in interfaceMAccumulator<IN,Counter<IN>>
-
value
public Counter<IN> value()
Description copied from interface:MAccumulator
The value of the accumulator.- Specified by:
value
in interfaceMAccumulator<IN,Counter<IN>>
- Returns:
- the result of the accumulator
-
isZero
public boolean isZero()
Description copied from interface:MAccumulator
Determines if the accumulator is a zero value- Specified by:
isZero
in interfaceMAccumulator<IN,Counter<IN>>
- Returns:
- True if the accumulator is in a zero state
-
copy
public LocalMAccumulator<IN,Counter<IN>> copy()
Description copied from interface:Copyable
Makes a copy of this object.
-
increment
public void increment(IN item, double amount)
Description copied from interface:MCounterAccumulator
Increments the given item by the given amount.- Specified by:
increment
in interfaceMCounterAccumulator<IN>
- Parameters:
item
- the item to incrementamount
- the amount to increment the item by
-
merge
public void merge(Counter<? extends IN> counter)
Description copied from interface:MCounterAccumulator
Merges the given counter with this accumulator- Specified by:
merge
in interfaceMCounterAccumulator<IN>
- Parameters:
counter
- the counter to merge
-
-