Class SimpleVersionedListState<T>
- java.lang.Object
-
- org.apache.flink.streaming.api.operators.util.SimpleVersionedListState<T>
-
- Type Parameters:
T
- The type of the objects stored in the state.
- All Implemented Interfaces:
AppendingState<T,Iterable<T>>
,ListState<T>
,MergingState<T,Iterable<T>>
,State
public class SimpleVersionedListState<T> extends Object implements ListState<T>
AListState
that uses aSimpleVersionedSerializer
instead of aTypeSerializer
.The state wraps a
ListState
of typebyte[]
, meaning it internally keeps only bytes and lazily deserializes them into objects. This has two major implications, compared to aListState
states that uses aTypeSerializer
:- This state does not participate in >state migration. The bytes are never converted and different state versions are lazily resolved by the versioned serializer.
- This state is generally slower than states that directly use the
TypeSerializer
, because of extra copies into byte arrays and extra version encodings.
-
-
Constructor Summary
Constructors Constructor Description SimpleVersionedListState(ListState<byte[]> rawState, SimpleVersionedSerializer<T> serializer)
Creates a new SimpleVersionedListState that reads and writes bytes from the given raw ListState with the given serializer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T value)
Updates the operator state accessible byAppendingState.get()
by adding the given value to the list of values.void
addAll(List<T> values)
Updates the operator state accessible byAppendingState.get()
by adding the given values to existing list of values.void
clear()
Removes the value mapped under the current key.Iterable<T>
get()
Returns the current value for the state.void
update(List<T> values)
Updates the operator state accessible byAppendingState.get()
by updating existing values to the given list of values.
-
-
-
Constructor Detail
-
SimpleVersionedListState
public SimpleVersionedListState(ListState<byte[]> rawState, SimpleVersionedSerializer<T> serializer)
Creates a new SimpleVersionedListState that reads and writes bytes from the given raw ListState with the given serializer.
-
-
Method Detail
-
update
public void update(@Nullable List<T> values) throws Exception
Description copied from interface:ListState
Updates the operator state accessible byAppendingState.get()
by updating existing values to the given list of values. The next timeAppendingState.get()
is called (for the same state partition) the returned state will represent the updated list.If an empty list is passed in, the state value will be null.
Null value passed in or any null value in list is not allowed.
-
addAll
public void addAll(@Nullable List<T> values) throws Exception
Description copied from interface:ListState
Updates the operator state accessible byAppendingState.get()
by adding the given values to existing list of values. The next timeAppendingState.get()
is called (for the same state partition) the returned state will represent the updated list.If an empty list is passed in, the state value remains unchanged.
Null value passed in or any null value in list is not allowed.
-
get
public Iterable<T> get() throws Exception
Description copied from interface:AppendingState
Returns the current value for the state. When the state is not partitioned the returned value is the same for all inputs in a given operator instance. If state partitioning is applied, the value returned depends on the current operator input, as the operator maintains an independent state for each partition.NOTE TO IMPLEMENTERS: if the state is empty, then this method should return
null
.
-
add
public void add(T value) throws Exception
Description copied from interface:AppendingState
Updates the operator state accessible byAppendingState.get()
by adding the given value to the list of values. The next timeAppendingState.get()
is called (for the same state partition) the returned state will represent the updated list.If null is passed in, the behaviour is undefined (implementation related). TODO: An unified behaviour across all sub-classes.
-
-