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 ValueState<T> & KvState<K,N,ValueState<T>,ValueStateDescriptor<T>,Backend>> extends Object implements ReducingState<T>, KvState<K,N,ReducingState<T>,ReducingStateDescriptor<T>,Backend>
ReducingState
based on a wrapped ValueState
.Constructor and Description |
---|
GenericReducingState(ValueState<T> wrappedState,
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,ReducingState<T>,ReducingStateDescriptor<T>,Backend> |
snapshot(long checkpointId,
long timestamp)
Creates a snapshot of this state.
|
public GenericReducingState(ValueState<T> wrappedState, 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,ReducingState<T>,ReducingStateDescriptor<T>,Backend extends AbstractStateBackend>
key
- The key.public void setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<K,N,ReducingState<T>,ReducingStateDescriptor<T>,Backend extends AbstractStateBackend>
namespace
- The namespace.public KvStateSnapshot<K,N,ReducingState<T>,ReducingStateDescriptor<T>,Backend> snapshot(long checkpointId, long timestamp) throws Exception
KvState
snapshot
in interface KvState<K,N,ReducingState<T>,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
dispose
in interface KvState<K,N,ReducingState<T>,ReducingStateDescriptor<T>,Backend extends AbstractStateBackend>
public T get() throws Exception
get
in interface MergingState<T,T>
Exception
public void add(T value) throws Exception
add
in interface MergingState<T,T>
Exception
Copyright © 2014–2016 The Apache Software Foundation. All rights reserved.