T
- The type of the values that can be added to the list state.@PublicEvolving public class ListStateDescriptor<T> extends StateDescriptor<ListState<T>,List<T>>
StateDescriptor
for ListState
. This can be used to create state where the type
is a list that can be appended and iterated over.
Using ListState
is typically more efficient than manually maintaining a list in a
ValueState
, because the backing implementation can support efficient appends, rather than
replacing the full list on write.
To create keyed list state (on a KeyedStream), use RuntimeContext.getListState(ListStateDescriptor)
.
StateDescriptor.Type
defaultValue, name
Constructor and Description |
---|
ListStateDescriptor(String name,
Class<T> elementTypeClass)
Creates a new
ListStateDescriptor with the given name and list element type. |
ListStateDescriptor(String name,
TypeInformation<T> elementTypeInfo)
Creates a new
ListStateDescriptor with the given name and list element type. |
ListStateDescriptor(String name,
TypeSerializer<T> typeSerializer)
Creates a new
ListStateDescriptor with the given name and list element type. |
Modifier and Type | Method and Description |
---|---|
TypeSerializer<T> |
getElementSerializer()
Gets the serializer for the elements contained in the list.
|
StateDescriptor.Type |
getType() |
enableTimeToLive, equals, getDefaultValue, getName, getQueryableStateName, getSerializer, getTtlConfig, hashCode, initializeSerializerUnlessSet, initializeSerializerUnlessSet, isQueryable, isSerializerInitialized, setQueryable, toString
public ListStateDescriptor(String name, Class<T> elementTypeClass)
ListStateDescriptor
with the given name and list element type.
If this constructor fails (because it is not possible to describe the type via a class),
consider using the ListStateDescriptor(String, TypeInformation)
constructor.
name
- The (unique) name for the state.elementTypeClass
- The type of the elements in the state.public ListStateDescriptor(String name, TypeInformation<T> elementTypeInfo)
ListStateDescriptor
with the given name and list element type.name
- The (unique) name for the state.elementTypeInfo
- The type of the elements in the state.public ListStateDescriptor(String name, TypeSerializer<T> typeSerializer)
ListStateDescriptor
with the given name and list element type.name
- The (unique) name for the state.typeSerializer
- The type serializer for the list values.public TypeSerializer<T> getElementSerializer()
public StateDescriptor.Type getType()
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.