K
- The type of the key.N
- The type of the namespace.IN
- The type of the value added to the state.ACC
- The type of the value stored in the state (the accumulator type).OUT
- The type of the value returned from the state.public class HeapAggregatingState<K,N,IN,ACC,OUT> extends AbstractHeapMergingState<K,N,IN,ACC,OUT,AggregatingState<IN,OUT>> implements InternalAggregatingState<K,N,IN,ACC,OUT>
AggregatingState
that is
snapshotted into files.currentNamespace, keySerializer, namespaceSerializer, stateTable, valueSerializer
Constructor and Description |
---|
HeapAggregatingState(StateTable<K,N,ACC> stateTable,
TypeSerializer<K> keySerializer,
TypeSerializer<ACC> valueSerializer,
TypeSerializer<N> namespaceSerializer,
ACC defaultValue,
AggregateFunction<IN,ACC,OUT> aggregateFunction)
Creates a new key/value state for the given hash map of key/value pairs.
|
Modifier and Type | Method and Description |
---|---|
void |
add(IN value)
Updates the operator state accessible by
AppendingState.get() by adding the given value
to the list of values. |
OUT |
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<ACC> |
getValueSerializer()
Returns the
TypeSerializer for the type of value this state holds. |
protected ACC |
mergeState(ACC a,
ACC b) |
mergeNamespaces
clear, getDefaultValue, getSerializedValue, getStateTable, setCurrentNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
mergeNamespaces
getSerializedValue, setCurrentNamespace
public HeapAggregatingState(StateTable<K,N,ACC> stateTable, TypeSerializer<K> keySerializer, TypeSerializer<ACC> valueSerializer, TypeSerializer<N> namespaceSerializer, ACC defaultValue, AggregateFunction<IN,ACC,OUT> aggregateFunction)
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.aggregateFunction
- The aggregating function used for aggregating state.public TypeSerializer<K> getKeySerializer()
InternalKvState
TypeSerializer
for the type of key this state is associated to.getKeySerializer
in interface InternalKvState<K,N,ACC>
public TypeSerializer<N> getNamespaceSerializer()
InternalKvState
TypeSerializer
for the type of namespace this state is associated to.getNamespaceSerializer
in interface InternalKvState<K,N,ACC>
public TypeSerializer<ACC> getValueSerializer()
InternalKvState
TypeSerializer
for the type of value this state holds.getValueSerializer
in interface InternalKvState<K,N,ACC>
public OUT get()
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
get
in interface AppendingState<IN,OUT>
null
if the state is empty.public void add(IN 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<IN,OUT>
value
- The new value for the state.IOException
protected ACC mergeState(ACC a, ACC b) throws Exception
mergeState
in class AbstractHeapMergingState<K,N,IN,ACC,OUT,AggregatingState<IN,OUT>>
Exception
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.