Interface InternalKvState<K,​N,​V>

  • Type Parameters:
    K - The type of key the state is associated to
    N - The type of the namespace
    V - The type of values kept internally in state
    All Superinterfaces:
    org.apache.flink.api.common.state.State
    All Known Subinterfaces:
    InternalAggregatingState<K,​N,​IN,​SV,​OUT>, InternalAppendingState<K,​N,​IN,​SV,​OUT>, InternalListState<K,​N,​T>, InternalMapState<K,​N,​UK,​UV>, InternalMergingState<K,​N,​IN,​SV,​OUT>, InternalReducingState<K,​N,​T>, InternalValueState<K,​N,​T>
    All Known Implementing Classes:
    AbstractHeapState

    public interface InternalKvState<K,​N,​V>
    extends org.apache.flink.api.common.state.State
    The InternalKvState is the root of the internal state type hierarchy, similar to the State being the root of the public API state hierarchy.

    The internal state classes give access to the namespace getters and setters and access to additional functionality, like raw value access or state merging.

    The public API state hierarchy is intended to be programmed against by Flink applications. The internal state hierarchy holds all the auxiliary methods that are used by the runtime and not intended to be used by user applications. These internal methods are considered of limited use to users and only confusing, and are usually not regarded as stable across releases.

    Each specific type in the internal state hierarchy extends the type from the public state hierarchy:

                 State
                   |
                   +-------------------InternalKvState
                   |                         |
              MergingState                   |
                   |                         |
                   +-----------------InternalMergingState
                   |                         |
          +--------+------+                  |
          |               |                  |
     ReducingState    ListState        +-----+-----------------+
          |               |            |                       |
          +-----------+   +-----------   -----------------InternalListState
                      |                |
                      +---------InternalReducingState
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  InternalKvState.StateIncrementalVisitor<K,​N,​V>
      The state entry visitor which supports remove and update of the last returned entries.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
      Returns the TypeSerializer for the type of key this state is associated to.
      org.apache.flink.api.common.typeutils.TypeSerializer<N> getNamespaceSerializer()
      Returns the TypeSerializer for the type of namespace this state is associated to.
      byte[] getSerializedValue​(byte[] serializedKeyAndNamespace, org.apache.flink.api.common.typeutils.TypeSerializer<K> safeKeySerializer, org.apache.flink.api.common.typeutils.TypeSerializer<N> safeNamespaceSerializer, org.apache.flink.api.common.typeutils.TypeSerializer<V> safeValueSerializer)
      Returns the serialized value for the given key and namespace.
      InternalKvState.StateIncrementalVisitor<K,​N,​V> getStateIncrementalVisitor​(int recommendedMaxNumberOfReturnedRecords)
      Get global visitor of state entries.
      org.apache.flink.api.common.typeutils.TypeSerializer<V> getValueSerializer()
      Returns the TypeSerializer for the type of value this state holds.
      void setCurrentNamespace​(N namespace)
      Sets the current namespace, which will be used when using the state access methods.
      • Methods inherited from interface org.apache.flink.api.common.state.State

        clear
    • Method Detail

      • getKeySerializer

        org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
        Returns the TypeSerializer for the type of key this state is associated to.
      • getNamespaceSerializer

        org.apache.flink.api.common.typeutils.TypeSerializer<N> getNamespaceSerializer()
        Returns the TypeSerializer for the type of namespace this state is associated to.
      • getValueSerializer

        org.apache.flink.api.common.typeutils.TypeSerializer<V> getValueSerializer()
        Returns the TypeSerializer for the type of value this state holds.
      • setCurrentNamespace

        void setCurrentNamespace​(N namespace)
        Sets the current namespace, which will be used when using the state access methods.
        Parameters:
        namespace - The namespace.
      • getSerializedValue

        byte[] getSerializedValue​(byte[] serializedKeyAndNamespace,
                                  org.apache.flink.api.common.typeutils.TypeSerializer<K> safeKeySerializer,
                                  org.apache.flink.api.common.typeutils.TypeSerializer<N> safeNamespaceSerializer,
                                  org.apache.flink.api.common.typeutils.TypeSerializer<V> safeValueSerializer)
                           throws Exception
        Returns the serialized value for the given key and namespace.

        If no value is associated with key and namespace, null is returned.

        TO IMPLEMENTERS: This method is called by multiple threads. Anything stateful (e.g. serializers) should be either duplicated or protected from undesired consequences of concurrent invocations.

        Parameters:
        serializedKeyAndNamespace - Serialized key and namespace
        safeKeySerializer - A key serializer which is safe to be used even in multi-threaded context
        safeNamespaceSerializer - A namespace serializer which is safe to be used even in multi-threaded context
        safeValueSerializer - A value serializer which is safe to be used even in multi-threaded context
        Returns:
        Serialized value or null if no value is associated with the key and namespace.
        Throws:
        Exception - Exceptions during serialization are forwarded
      • getStateIncrementalVisitor

        InternalKvState.StateIncrementalVisitor<K,​N,​V> getStateIncrementalVisitor​(int recommendedMaxNumberOfReturnedRecords)
        Get global visitor of state entries.
        Parameters:
        recommendedMaxNumberOfReturnedRecords - hint to the visitor not to exceed this number of returned records per nextEntries call, it can still be exceeded by some smaller constant.
        Returns:
        global iterator over state entries