N
- The type of the namespace.T
- The type of the values stored in this ListState
.W
- Generic type that extends both the underlying ValueState
and KvState
.public class GenericListState<N,T,W extends ValueState<ArrayList<T>> & KvState<N>> extends Object implements ListState<T>, KvState<N>
ListState
based on a wrapped ValueState
.Constructor and Description |
---|
GenericListState(ValueState<ArrayList<T>> wrappedState)
Creates a new
ListState 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.
|
Iterable<T> |
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 GenericListState(ValueState<ArrayList<T>> wrappedState)
ListState
that wraps the given ValueState
. The
ValueState
must have a default value of null
.wrappedState
- The wrapped ValueState
public 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 Iterable<T> get() throws Exception
AppendingState
NOTE TO IMPLEMENTERS: if the state is empty, then this method
should return null
.
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,Iterable<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.