K
- The type of the key.N
- The type of the namespace.T
- The type of the values that can be folded into the state.ACC
- The type of the value in the folding state.Backend
- The type of AbstractStateBackend
that manages this KvState
.W
- Generic type that extends both the underlying ValueState
and KvState
.public class GenericFoldingState<K,N,T,ACC,Backend extends AbstractStateBackend,W extends ValueState<ACC> & KvState<K,N,ValueState<ACC>,ValueStateDescriptor<ACC>,Backend>> extends Object implements FoldingState<T,ACC>, KvState<K,N,FoldingState<T,ACC>,FoldingStateDescriptor<T,ACC>,Backend>
FoldingState
based on a wrapped ValueState
.Constructor and Description |
---|
GenericFoldingState(ValueState<ACC> wrappedState,
FoldFunction<T,ACC> foldFunction)
Creates a new
FoldingState that wraps the given ValueState . |
Modifier and Type | Method and Description |
---|---|
void |
add(T value)
Updates the operator state accessible by
AppendingState.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.
|
ACC |
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,FoldingState<T,ACC>,FoldingStateDescriptor<T,ACC>,Backend> |
snapshot(long checkpointId,
long timestamp)
Creates a snapshot of this state.
|
public GenericFoldingState(ValueState<ACC> wrappedState, FoldFunction<T,ACC> foldFunction)
FoldingState
that wraps the given ValueState
. The
ValueState
must have the initial value of the fold as default value.wrappedState
- The wrapped ValueState
foldFunction
- The FoldFunction
to use for folding values into the statepublic void setCurrentKey(K key)
KvState
setCurrentKey
in interface KvState<K,N,FoldingState<T,ACC>,FoldingStateDescriptor<T,ACC>,Backend extends AbstractStateBackend>
key
- The key.public void setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<K,N,FoldingState<T,ACC>,FoldingStateDescriptor<T,ACC>,Backend extends AbstractStateBackend>
namespace
- The namespace.public KvStateSnapshot<K,N,FoldingState<T,ACC>,FoldingStateDescriptor<T,ACC>,Backend> snapshot(long checkpointId, long timestamp) throws Exception
KvState
snapshot
in interface KvState<K,N,FoldingState<T,ACC>,FoldingStateDescriptor<T,ACC>,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,FoldingState<T,ACC>,FoldingStateDescriptor<T,ACC>,Backend extends AbstractStateBackend>
public ACC get() throws Exception
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
get
in interface AppendingState<T,ACC>
null
if the state is empty.Exception
- Thrown if the system cannot access the state.public void add(T value) throws Exception
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.add
in interface AppendingState<T,ACC>
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.