Class ListStateDescriptor<T>

  • Type Parameters:
    T - The type of the values that can be added to the list state.
    All Implemented Interfaces:
    Serializable

    @PublicEvolving
    public class ListStateDescriptor<T>
    extends StateDescriptor<org.apache.flink.api.common.state.ListState<T>,​List<T>>
    A 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).

    See Also:
    Serialized Form
    • Constructor Detail

      • ListStateDescriptor

        public ListStateDescriptor​(String name,
                                   Class<T> elementTypeClass)
        Creates a new 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.

        Parameters:
        name - The (unique) name for the state.
        elementTypeClass - The type of the elements in the state.
      • ListStateDescriptor

        public ListStateDescriptor​(String name,
                                   TypeInformation<T> elementTypeInfo)
        Creates a new ListStateDescriptor with the given name and list element type.
        Parameters:
        name - The (unique) name for the state.
        elementTypeInfo - The type of the elements in the state.
      • ListStateDescriptor

        public ListStateDescriptor​(String name,
                                   TypeSerializer<T> typeSerializer)
        Creates a new ListStateDescriptor with the given name and list element type.
        Parameters:
        name - The (unique) name for the state.
        typeSerializer - The type serializer for the list values.
    • Method Detail

      • getElementSerializer

        public TypeSerializer<T> getElementSerializer()
        Gets the serializer for the elements contained in the list.
        Returns:
        The serializer for the elements in the list.