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.W
- Generic type that extends both the underlying ValueState
and KvState
.public class GenericFoldingState<N,T,ACC,W extends ValueState<ACC> & KvState<N>> extends Object implements FoldingState<T,ACC>, KvState<N>
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.
|
ACC |
get()
Returns the current value for the state.
|
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace)
Returns the serialized value for the given key and namespace.
|
void |
setCurrentNamespace(N namespace)
Sets the current namespace, which will be used when using the state access methods.
|
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 setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<N>
namespace
- The namespace.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace) throws Exception
KvState
If no value is associated with key and namespace, null
is returned.
getSerializedValue
in interface KvState<N>
serializedKeyAndNamespace
- Serialized key and namespacenull
if no value is associated
with the key and namespace.Exception
- Exceptions during serialization are forwardedpublic 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.