K
- The type of the key.N
- The type of the namespace.V
- The type of the value.public class HeapReducingState<K,N,V> extends AbstractHeapMergingState<K,N,V,V,V,ReducingState<V>> implements InternalReducingState<K,N,V>
ReducingState
that is snapshotted into files.currentNamespace, keySerializer, namespaceSerializer, stateTable, valueSerializer
Constructor and Description |
---|
HeapReducingState(StateTable<K,N,V> stateTable,
TypeSerializer<K> keySerializer,
TypeSerializer<V> valueSerializer,
TypeSerializer<N> namespaceSerializer,
V defaultValue,
ReduceFunction<V> reduceFunction)
Creates a new key/value state for the given hash map of key/value pairs.
|
Modifier and Type | Method and Description |
---|---|
void |
add(V value)
Updates the operator state accessible by
AppendingState.get() by adding the given value
to the list of values. |
V |
get()
Returns the current value for the state.
|
TypeSerializer<K> |
getKeySerializer()
Returns the
TypeSerializer for the type of key this state is associated to. |
TypeSerializer<N> |
getNamespaceSerializer()
Returns the
TypeSerializer for the type of namespace this state is associated to. |
TypeSerializer<V> |
getValueSerializer()
Returns the
TypeSerializer for the type of value this state holds. |
protected V |
mergeState(V a,
V b) |
mergeNamespaces
clear, getDefaultValue, getSerializedValue, getStateTable, setCurrentNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
mergeNamespaces
getSerializedValue, setCurrentNamespace
public HeapReducingState(StateTable<K,N,V> stateTable, TypeSerializer<K> keySerializer, TypeSerializer<V> valueSerializer, TypeSerializer<N> namespaceSerializer, V defaultValue, ReduceFunction<V> reduceFunction)
stateTable
- The state table for which this state is associated to.keySerializer
- The serializer for the keys.valueSerializer
- The serializer for the state.namespaceSerializer
- The serializer for the namespace.defaultValue
- The default value for the state.reduceFunction
- The reduce function used for reducing state.public TypeSerializer<K> getKeySerializer()
InternalKvState
TypeSerializer
for the type of key this state is associated to.getKeySerializer
in interface InternalKvState<K,N,V>
public TypeSerializer<N> getNamespaceSerializer()
InternalKvState
TypeSerializer
for the type of namespace this state is associated to.getNamespaceSerializer
in interface InternalKvState<K,N,V>
public TypeSerializer<V> getValueSerializer()
InternalKvState
TypeSerializer
for the type of value this state holds.getValueSerializer
in interface InternalKvState<K,N,V>
public V get()
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
get
in interface AppendingState<V,V>
null
if the state is empty.public void add(V value) throws IOException
AppendingState
AppendingState.get()
by adding the given value
to the list of values. The next time AppendingState.get()
is called (for the same state
partition) the returned state will represent the updated list.
If null is passed in, the state value will remain unchanged.
add
in interface AppendingState<V,V>
value
- The new value for the state.IOException
protected V mergeState(V a, V b) throws Exception
mergeState
in class AbstractHeapMergingState<K,N,V,V,V,ReducingState<V>>
Exception
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.