K
- The type of the key.V
- The type of the value.Backend
- The type of the backend that snapshots this key/value state.public abstract class AbstractHeapKvState<K,V,Backend extends StateBackend<Backend>> extends Object implements KvState<K,V,Backend>
Modifier | Constructor and Description |
---|---|
protected |
AbstractHeapKvState(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer,
V defaultValue)
Creates a new empty key/value state.
|
protected |
AbstractHeapKvState(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer,
V defaultValue,
HashMap<K,V> state)
Creates a new key/value state for the given hash map of key/value pairs.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Disposes the key/value state, releasing all occupied resources.
|
org.apache.flink.api.common.typeutils.TypeSerializer<K> |
getKeySerializer()
Gets the serializer for the keys.
|
org.apache.flink.api.common.typeutils.TypeSerializer<V> |
getValueSerializer()
Gets the serializer for the values.
|
void |
setCurrentKey(K currentKey)
Sets the current key, which will be used to retrieve values for the next calls to
OperatorState.value() and OperatorState.update(Object) . |
int |
size()
Gets the number of key/value pairs currently stored in the state.
|
void |
update(V value) |
V |
value() |
protected void |
writeStateToOutputView(org.apache.flink.core.memory.DataOutputView out) |
protected AbstractHeapKvState(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer, V defaultValue)
keySerializer
- The serializer for the keys.valueSerializer
- The serializer for the values.defaultValue
- The value that is returned when no other value has been associated with a key, yet.protected AbstractHeapKvState(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer, V defaultValue, HashMap<K,V> state)
keySerializer
- The serializer for the keys.valueSerializer
- The serializer for the values.defaultValue
- The value that is returned when no other value has been associated with a key, yet.state
- The state map to use in this kev/value state. May contain initial state.public V value()
value
in interface org.apache.flink.api.common.state.OperatorState<V>
public void update(V value)
update
in interface org.apache.flink.api.common.state.OperatorState<V>
public void setCurrentKey(K currentKey)
KvState
OperatorState.value()
and OperatorState.update(Object)
.setCurrentKey
in interface KvState<K,V,Backend extends StateBackend<Backend>>
currentKey
- The key.public int size()
KvState
public void dispose()
KvState
public org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
public org.apache.flink.api.common.typeutils.TypeSerializer<V> getValueSerializer()
protected void writeStateToOutputView(org.apache.flink.core.memory.DataOutputView out) throws IOException
IOException
Copyright © 2014–2015 The Apache Software Foundation. All rights reserved.