Class AbstractHeapState<K,​N,​SV>

  • Type Parameters:
    K - The type of the key.
    N - The type of the namespace.
    SV - The type of the values in the state.
    All Implemented Interfaces:
    State, InternalKvState<K,​N,​SV>

    public abstract class AbstractHeapState<K,​N,​SV>
    extends Object
    implements InternalKvState<K,​N,​SV>
    Base class for partitioned State implementations that are backed by a regular heap hash map. The concrete implementations define how the state is checkpointed.
    • Field Detail

      • stateTable

        protected final StateTable<K,​N,​SV> stateTable
        Map containing the actual key/value pairs.
      • currentNamespace

        protected N currentNamespace
        The current namespace, which the access methods will refer to.
    • Method Detail

      • clear

        public final void clear()
        Description copied from interface: State
        Removes the value mapped under the current key.
        Specified by:
        clear in interface State
      • setCurrentNamespace

        public final void setCurrentNamespace​(N namespace)
        Description copied from interface: InternalKvState
        Sets the current namespace, which will be used when using the state access methods.
        Specified by:
        setCurrentNamespace in interface InternalKvState<K,​N,​SV>
        Parameters:
        namespace - The namespace.
      • getSerializedValue

        public byte[] getSerializedValue​(byte[] serializedKeyAndNamespace,
                                         TypeSerializer<K> safeKeySerializer,
                                         TypeSerializer<N> safeNamespaceSerializer,
                                         TypeSerializer<SV> safeValueSerializer)
                                  throws Exception
        Description copied from interface: InternalKvState
        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.

        Specified by:
        getSerializedValue in interface InternalKvState<K,​N,​SV>
        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
      • getDefaultValue

        protected SV getDefaultValue()
      • getStateIncrementalVisitor

        public InternalKvState.StateIncrementalVisitor<K,​N,​SV> getStateIncrementalVisitor​(int recommendedMaxNumberOfReturnedRecords)
        Description copied from interface: InternalKvState
        Get global visitor of state entries.
        Specified by:
        getStateIncrementalVisitor in interface InternalKvState<K,​N,​SV>
        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