K
- The type of the key.N
- The type of the namespace.V
- The type of the value.public class HeapListState<K,N,V> extends AbstractHeapMergingState<K,N,V,List<V>,Iterable<V>,ListState<V>> implements InternalListState<K,N,V>
ListState
that is snapshotted into files.currentNamespace, keySerializer, namespaceSerializer, stateTable, valueSerializer
Constructor and Description |
---|
HeapListState(StateTable<K,N,List<V>> stateTable,
TypeSerializer<K> keySerializer,
TypeSerializer<List<V>> valueSerializer,
TypeSerializer<N> namespaceSerializer,
List<V> defaultValue)
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. |
void |
addAll(List<V> values)
Updates the operator state accessible by
AppendingState.get() by adding the given values
to existing list of values. |
Iterable<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. |
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace,
TypeSerializer<K> safeKeySerializer,
TypeSerializer<N> safeNamespaceSerializer,
TypeSerializer<List<V>> safeValueSerializer)
Returns the serialized value for the given key and namespace.
|
TypeSerializer<List<V>> |
getValueSerializer()
Returns the
TypeSerializer for the type of value this state holds. |
protected List<V> |
mergeState(List<V> a,
List<V> b) |
void |
update(List<V> values)
Updates the operator state accessible by
AppendingState.get() by updating existing values to
to the given list of values. |
mergeNamespaces
clear, getDefaultValue, getStateTable, setCurrentNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
mergeNamespaces
setCurrentNamespace
public HeapListState(StateTable<K,N,List<V>> stateTable, TypeSerializer<K> keySerializer, TypeSerializer<List<V>> valueSerializer, TypeSerializer<N> namespaceSerializer, List<V> defaultValue)
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.public TypeSerializer<K> getKeySerializer()
InternalKvState
TypeSerializer
for the type of key this state is associated to.getKeySerializer
in interface InternalKvState<K,N,List<V>>
public TypeSerializer<N> getNamespaceSerializer()
InternalKvState
TypeSerializer
for the type of namespace this state is associated to.getNamespaceSerializer
in interface InternalKvState<K,N,List<V>>
public TypeSerializer<List<V>> getValueSerializer()
InternalKvState
TypeSerializer
for the type of value this state holds.getValueSerializer
in interface InternalKvState<K,N,List<V>>
public Iterable<V> get()
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
get
in interface AppendingState<V,Iterable<V>>
null
if the state is empty.public void add(V value)
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,Iterable<V>>
value
- The new value for the state.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace, TypeSerializer<K> safeKeySerializer, TypeSerializer<N> safeNamespaceSerializer, TypeSerializer<List<V>> safeValueSerializer) throws Exception
InternalKvState
If no value is associated with key and namespace, null
is returned.
TO IMPLEMENTERS: This method is called by multiple threads. Anything stateful (e.g. serializers) should be either duplicated or protected from undesired consequences of concurrent invocations.
getSerializedValue
in interface InternalKvState<K,N,List<V>>
getSerializedValue
in class AbstractHeapState<K,N,List<V>,ListState<V>>
serializedKeyAndNamespace
- Serialized key and namespacesafeKeySerializer
- A key serializer which is safe to be used even in multi-threaded contextsafeNamespaceSerializer
- A namespace serializer which is safe to be used even in multi-threaded contextsafeValueSerializer
- A value serializer which is safe to be used even in multi-threaded contextnull
if no value is associated with the key and namespace.Exception
- Exceptions during serialization are forwardedpublic void update(List<V> values) throws Exception
InternalListState
AppendingState.get()
by updating existing values to
to the given 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` or an empty list is passed in, the state value will be nullpublic void addAll(List<V> values) throws Exception
InternalListState
AppendingState.get()
by adding the given values
to existing 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` or an empty list is passed in, the state value remains unchangedCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.