Package com.gengoai.stream.local
Class LocalMMultiCounterAccumulator<K1,K2>
- java.lang.Object
-
- com.gengoai.stream.local.LocalMAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>>
-
- com.gengoai.stream.local.LocalMMultiCounterAccumulator<K1,K2>
-
- Type Parameters:
K1
- the first key type parameter of the MultiCounterK2
- the second key type parameter of the MultiCounter
- All Implemented Interfaces:
Copyable<LocalMAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>>>
,MAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>>
,MMultiCounterAccumulator<K1,K2>
,Serializable
public class LocalMMultiCounterAccumulator<K1,K2> extends LocalMAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>> implements MMultiCounterAccumulator<K1,K2>
An implementation of a
MMultiCounterAccumulator
for local streams- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LocalMMultiCounterAccumulator(String name)
Instantiates a new LocalMMultiCounterAccumulator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Tuple2<K1,K2> objects)
Adds an item to the accumulatorLocalMAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>>
copy()
Makes a copy of this object.void
increment(K1 firstKey, K2 secondKey)
Increments the count of the two keys.void
increment(K1 firstKey, K2 secondKey, double value)
Increments the count of the two keys by the given value.boolean
isZero()
Determines if the accumulator is a zero valuevoid
merge(MultiCounter<K1,K2> other)
Merges the given MultiCounter with this accumulatorvoid
merge(MAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>> other)
Merges another accumulator with this onevoid
reset()
Resets the accumulator to its zero-value.MultiCounter<K1,K2>
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
-
LocalMMultiCounterAccumulator
public LocalMMultiCounterAccumulator(String name)
Instantiates a new LocalMMultiCounterAccumulator.- Parameters:
name
- the name of the accumulator
-
-
Method Detail
-
add
public void add(Tuple2<K1,K2> objects)
Description copied from interface:MAccumulator
Adds an item to the accumulator- Specified by:
add
in interfaceMAccumulator<K1,K2>
- Parameters:
objects
- the item to add
-
copy
public LocalMAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>> copy()
Description copied from interface:Copyable
Makes a copy of this object.
-
value
public MultiCounter<K1,K2> value()
Description copied from interface:MAccumulator
The value of the accumulator.- Specified by:
value
in interfaceMAccumulator<K1,K2>
- 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<K1,K2>
- Returns:
- True if the accumulator is in a zero state
-
merge
public void merge(MAccumulator<Tuple2<K1,K2>,MultiCounter<K1,K2>> other)
Description copied from interface:MAccumulator
Merges another accumulator with this one- Specified by:
merge
in interfaceMAccumulator<K1,K2>
- 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<K1,K2>
-
increment
public void increment(K1 firstKey, K2 secondKey)
Description copied from interface:MMultiCounterAccumulator
Increments the count of the two keys.- Specified by:
increment
in interfaceMMultiCounterAccumulator<K1,K2>
- Parameters:
firstKey
- the first keysecondKey
- the second key
-
increment
public void increment(K1 firstKey, K2 secondKey, double value)
Description copied from interface:MMultiCounterAccumulator
Increments the count of the two keys by the given value.- Specified by:
increment
in interfaceMMultiCounterAccumulator<K1,K2>
- Parameters:
firstKey
- the first keysecondKey
- the second keyvalue
- the amount to increment by
-
merge
public void merge(MultiCounter<K1,K2> other)
Description copied from interface:MMultiCounterAccumulator
Merges the given MultiCounter with this accumulator- Specified by:
merge
in interfaceMMultiCounterAccumulator<K1,K2>
- Parameters:
other
- the MultiCounter to merge
-
-