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)
Updates the operator state accessible by
MergingState.get() by adding the given value
to the list of values. |
void |
clear()
Removes the value mapped under the current key.
|
void |
dispose()
Disposes the key/value state, releasing all occupied resources.
|
T |
get()
Returns the current value for the state.
|
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
MergingState
get
in interface MergingState<T,T>
Exception
- Thrown if the system cannot access the state.public void add(T value) throws Exception
MergingState
MergingState.get()
by adding the given value
to the list of values. The next time MergingState.get()
is called (for the same state
partition) the returned state will represent the updated list.add
in interface MergingState<T,T>
value
- The new value for the state.IOException
- Thrown if the system cannot access the state.Exception
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.