Package com.gengoai.stream.local
Class LocalMMapAccumulator<K,V>
- java.lang.Object
-
- com.gengoai.stream.local.LocalMAccumulator<Tuple2<K,V>,Map<K,V>>
-
- com.gengoai.stream.local.LocalMMapAccumulator<K,V>
-
- Type Parameters:
K
- the key type parameter of the mapV
- the value type parameter of the map
- All Implemented Interfaces:
Copyable<LocalMAccumulator<Tuple2<K,V>,Map<K,V>>>
,MAccumulator<Tuple2<K,V>,Map<K,V>>
,MMapAccumulator<K,V>
,Serializable
public class LocalMMapAccumulator<K,V> extends LocalMAccumulator<Tuple2<K,V>,Map<K,V>> implements MMapAccumulator<K,V>
An implementation of a
MMapAccumulator
for local streams- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LocalMMapAccumulator(String name)
Instantiates a new LocalMMapAccumulator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Tuple2<K,V> objects)
Adds an item to the accumulatorLocalMAccumulator<Tuple2<K,V>,Map<K,V>>
copy()
Makes a copy of this object.boolean
isZero()
Determines if the accumulator is a zero valuevoid
merge(MAccumulator<Tuple2<K,V>,Map<K,V>> other)
Merges another accumulator with this onevoid
put(K key, V value)
Adds the given key-value pair ot the mapvoid
putAll(Map<? extends K,? extends V> other)
Adds all entries of the given map overriding any current entries.void
reset()
Resets the accumulator to its zero-value.Map<K,V>
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
-
LocalMMapAccumulator
public LocalMMapAccumulator(String name)
Instantiates a new LocalMMapAccumulator.- Parameters:
name
- the name of the accumulator
-
-
Method Detail
-
add
public void add(Tuple2<K,V> objects)
Description copied from interface:MAccumulator
Adds an item to the accumulator- Specified by:
add
in interfaceMAccumulator<K,V>
- Parameters:
objects
- the item to add
-
copy
public LocalMAccumulator<Tuple2<K,V>,Map<K,V>> copy()
Description copied from interface:Copyable
Makes a copy of this object.
-
value
public Map<K,V> value()
Description copied from interface:MAccumulator
The value of the accumulator.- Specified by:
value
in interfaceMAccumulator<K,V>
- 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<K,V>
- Returns:
- True if the accumulator is in a zero state
-
merge
public void merge(MAccumulator<Tuple2<K,V>,Map<K,V>> other)
Description copied from interface:MAccumulator
Merges another accumulator with this one- Specified by:
merge
in interfaceMAccumulator<K,V>
- 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<K,V>
-
put
public void put(K key, V value)
Description copied from interface:MMapAccumulator
Adds the given key-value pair ot the map- Specified by:
put
in interfaceMMapAccumulator<K,V>
- Parameters:
key
- the key to addvalue
- the value to associate with the key
-
putAll
public void putAll(Map<? extends K,? extends V> other)
Description copied from interface:MMapAccumulator
Adds all entries of the given map overriding any current entries.- Specified by:
putAll
in interfaceMMapAccumulator<K,V>
- Parameters:
other
- the map whose key-value pairs are to be added
-
-