K
- The type of the key.N
- The type of the namespace.T
- The type of the values stored in this ReducingState
.Backend
- The type of AbstractStateBackend
that manages this KvState
.W
- Generic type that extends both the underlying ValueState
and KvState
.public class GenericReducingState<K,N,T,Backend extends AbstractStateBackend,W extends org.apache.flink.api.common.state.ValueState<T> & KvState<K,N,org.apache.flink.api.common.state.ValueState<T>,org.apache.flink.api.common.state.ValueStateDescriptor<T>,Backend>> extends Object implements org.apache.flink.api.common.state.ReducingState<T>, KvState<K,N,org.apache.flink.api.common.state.ReducingState<T>,org.apache.flink.api.common.state.ReducingStateDescriptor<T>,Backend>
ReducingState
based on a wrapped ValueState
.Constructor and Description |
---|
GenericReducingState(org.apache.flink.api.common.state.ValueState<T> wrappedState,
org.apache.flink.api.common.functions.ReduceFunction<T> reduceFunction)
Creates a new
ReducingState that wraps the given ValueState . |
Modifier and Type | Method and Description |
---|---|
void |
add(T value) |
void |
clear() |
void |
dispose()
Disposes the key/value state, releasing all occupied resources.
|
T |
get() |
void |
setCurrentKey(K key)
Sets the current key, which will be used when using the state access methods.
|
void |
setCurrentNamespace(N namespace)
Sets the current namespace, which will be used when using the state access methods.
|
KvStateSnapshot<K,N,org.apache.flink.api.common.state.ReducingState<T>,org.apache.flink.api.common.state.ReducingStateDescriptor<T>,Backend> |
snapshot(long checkpointId,
long timestamp)
Creates a snapshot of this state.
|
public GenericReducingState(org.apache.flink.api.common.state.ValueState<T> wrappedState, org.apache.flink.api.common.functions.ReduceFunction<T> reduceFunction)
ReducingState
that wraps the given ValueState
. The
ValueState
must have a default value of null
.wrappedState
- The wrapped ValueState
reduceFunction
- The ReduceFunction
to use for combining values.public void setCurrentKey(K key)
KvState
setCurrentKey
in interface KvState<K,N,org.apache.flink.api.common.state.ReducingState<T>,org.apache.flink.api.common.state.ReducingStateDescriptor<T>,Backend extends AbstractStateBackend>
key
- The key.public void setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<K,N,org.apache.flink.api.common.state.ReducingState<T>,org.apache.flink.api.common.state.ReducingStateDescriptor<T>,Backend extends AbstractStateBackend>
namespace
- The namespace.public KvStateSnapshot<K,N,org.apache.flink.api.common.state.ReducingState<T>,org.apache.flink.api.common.state.ReducingStateDescriptor<T>,Backend> snapshot(long checkpointId, long timestamp) throws Exception
KvState
snapshot
in interface KvState<K,N,org.apache.flink.api.common.state.ReducingState<T>,org.apache.flink.api.common.state.ReducingStateDescriptor<T>,Backend extends AbstractStateBackend>
checkpointId
- The ID of the checkpoint for which the snapshot should be created.timestamp
- The timestamp of the checkpoint.Exception
- Exceptions during snapshotting the state should be forwarded, so the system
can react to failed snapshots.public void dispose()
KvState
public void clear()
clear
in interface org.apache.flink.api.common.state.State
Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.