Class BatchExecutionKeyedStateBackend<K>

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>, org.apache.flink.runtime.state.KeyedStateBackend<K>, org.apache.flink.runtime.state.KeyedStateFactory, org.apache.flink.runtime.state.PriorityQueueSetFactory, org.apache.flink.runtime.state.Snapshotable<org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle>>, org.apache.flink.util.Disposable

    public class BatchExecutionKeyedStateBackend<K>
    extends Object
    implements org.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>
    A CheckpointableKeyedStateBackend which keeps values for a single key at a time.

    IMPORTANT: Requires the incoming records to be sorted/grouped by the key. Used in a BATCH style execution.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.KeyedStateBackend

        org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K extends Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      BatchExecutionKeyedStateBackend​(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer, org.apache.flink.runtime.state.KeyGroupRange keyGroupRange, org.apache.flink.api.common.ExecutionConfig executionConfig)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <N,​S extends org.apache.flink.api.common.state.State,​T>
      void
      applyToAllKeys​(N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S,​T> stateDescriptor, org.apache.flink.runtime.state.KeyedStateFunction<K,​S> function)  
      void close()  
      <T extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement & org.apache.flink.runtime.state.PriorityComparable<? super T> & org.apache.flink.runtime.state.Keyed<?>>
      org.apache.flink.runtime.state.KeyGroupedInternalPriorityQueue<T>
      create​(String stateName, org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer)  
      <N,​SV,​SEV,​S extends org.apache.flink.api.common.state.State,​IS extends S>
      IS
      createOrUpdateInternalState​(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S,​SV> stateDesc, org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory)  
      boolean deregisterKeySelectionListener​(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener)  
      void dispose()  
      K getCurrentKey()  
      org.apache.flink.runtime.state.KeyGroupRange getKeyGroupRange()  
      <N> java.util.stream.Stream<K> getKeys​(String state, N namespace)  
      <N> java.util.stream.Stream<K> getKeys​(List<String> states, N namespace)  
      <N> java.util.stream.Stream<org.apache.flink.api.java.tuple.Tuple2<K,​N>> getKeysAndNamespaces​(String state)  
      org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()  
      <N,​S extends org.apache.flink.api.common.state.State,​T>
      S
      getOrCreateKeyedState​(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S,​T> stateDescriptor)  
      <N,​S extends org.apache.flink.api.common.state.State>
      S
      getPartitionedState​(N namespace, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.state.StateDescriptor<S,​?> stateDescriptor)  
      void registerKeySelectionListener​(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener)  
      org.apache.flink.runtime.state.SavepointResources<K> savepoint()  
      void setCurrentKey​(K newKey)  
      RunnableFuture<org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle>> snapshot​(long checkpointId, long timestamp, org.apache.flink.runtime.state.CheckpointStreamFactory streamFactory, org.apache.flink.runtime.checkpoint.CheckpointOptions checkpointOptions)  
      • Methods inherited from interface org.apache.flink.runtime.state.KeyedStateBackend

        isSafeToReuseKVState, isStateImmutableInStateBackend
      • Methods inherited from interface org.apache.flink.runtime.state.KeyedStateFactory

        createOrUpdateInternalState, createOrUpdateInternalState
      • Methods inherited from interface org.apache.flink.runtime.state.PriorityQueueSetFactory

        create
    • Constructor Detail

      • BatchExecutionKeyedStateBackend

        public BatchExecutionKeyedStateBackend​(org.apache.flink.api.common.typeutils.TypeSerializer<K> keySerializer,
                                               org.apache.flink.runtime.state.KeyGroupRange keyGroupRange,
                                               org.apache.flink.api.common.ExecutionConfig executionConfig)
    • Method Detail

      • setCurrentKey

        public void setCurrentKey​(K newKey)
        Specified by:
        setCurrentKey in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • getCurrentKey

        public K getCurrentKey()
        Specified by:
        getCurrentKey in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • getKeySerializer

        public org.apache.flink.api.common.typeutils.TypeSerializer<K> getKeySerializer()
        Specified by:
        getKeySerializer in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • applyToAllKeys

        public <N,​S extends org.apache.flink.api.common.state.State,​T> void applyToAllKeys​(N namespace,
                                                                                                       org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                                                       org.apache.flink.api.common.state.StateDescriptor<S,​T> stateDescriptor,
                                                                                                       org.apache.flink.runtime.state.KeyedStateFunction<K,​S> function)
        Specified by:
        applyToAllKeys in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • getKeys

        public <N> java.util.stream.Stream<K> getKeys​(String state,
                                                      N namespace)
        Specified by:
        getKeys in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • getKeys

        public <N> java.util.stream.Stream<K> getKeys​(List<String> states,
                                                      N namespace)
        Specified by:
        getKeys in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • getKeysAndNamespaces

        public <N> java.util.stream.Stream<org.apache.flink.api.java.tuple.Tuple2<K,​N>> getKeysAndNamespaces​(String state)
        Specified by:
        getKeysAndNamespaces in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • getOrCreateKeyedState

        public <N,​S extends org.apache.flink.api.common.state.State,​T> S getOrCreateKeyedState​(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                                                           org.apache.flink.api.common.state.StateDescriptor<S,​T> stateDescriptor)
                                                                                                    throws Exception
        Specified by:
        getOrCreateKeyedState in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
        Throws:
        Exception
      • getPartitionedState

        public <N,​S extends org.apache.flink.api.common.state.State> S getPartitionedState​(N namespace,
                                                                                                 org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                                                 org.apache.flink.api.common.state.StateDescriptor<S,​?> stateDescriptor)
                                                                                          throws Exception
        Specified by:
        getPartitionedState in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
        Throws:
        Exception
      • dispose

        public void dispose()
        Specified by:
        dispose in interface org.apache.flink.util.Disposable
        Specified by:
        dispose in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • registerKeySelectionListener

        public void registerKeySelectionListener​(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener)
        Specified by:
        registerKeySelectionListener in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • deregisterKeySelectionListener

        public boolean deregisterKeySelectionListener​(org.apache.flink.runtime.state.KeyedStateBackend.KeySelectionListener<K> listener)
        Specified by:
        deregisterKeySelectionListener in interface org.apache.flink.runtime.state.KeyedStateBackend<K>
      • createOrUpdateInternalState

        @Nonnull
        public <N,​SV,​SEV,​S extends org.apache.flink.api.common.state.State,​IS extends S> IS createOrUpdateInternalState​(@Nonnull
                                                                                                                                                org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                                                                                                                                @Nonnull
                                                                                                                                                org.apache.flink.api.common.state.StateDescriptor<S,​SV> stateDesc,
                                                                                                                                                @Nonnull
                                                                                                                                                org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory<SEV> snapshotTransformFactory)
                                                                                                                                         throws Exception
        Specified by:
        createOrUpdateInternalState in interface org.apache.flink.runtime.state.KeyedStateFactory
        Throws:
        Exception
      • create

        @Nonnull
        public <T extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement & org.apache.flink.runtime.state.PriorityComparable<? super T> & org.apache.flink.runtime.state.Keyed<?>> org.apache.flink.runtime.state.KeyGroupedInternalPriorityQueue<T> create​(@Nonnull
                                                                                                                                                                                                                                                                          String stateName,
                                                                                                                                                                                                                                                                          @Nonnull
                                                                                                                                                                                                                                                                          org.apache.flink.api.common.typeutils.TypeSerializer<T> byteOrderedElementSerializer)
        Specified by:
        create in interface org.apache.flink.runtime.state.PriorityQueueSetFactory
      • getKeyGroupRange

        public org.apache.flink.runtime.state.KeyGroupRange getKeyGroupRange()
        Specified by:
        getKeyGroupRange in interface org.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>
      • snapshot

        @Nonnull
        public RunnableFuture<org.apache.flink.runtime.state.SnapshotResult<org.apache.flink.runtime.state.KeyedStateHandle>> snapshot​(long checkpointId,
                                                                                                                                       long timestamp,
                                                                                                                                       @Nonnull
                                                                                                                                       org.apache.flink.runtime.state.CheckpointStreamFactory streamFactory,
                                                                                                                                       @Nonnull
                                                                                                                                       org.apache.flink.runtime.checkpoint.CheckpointOptions checkpointOptions)
        Specified by:
        snapshot in interface org.apache.flink.runtime.state.Snapshotable<K>
      • savepoint

        @Nonnull
        public org.apache.flink.runtime.state.SavepointResources<K> savepoint()
                                                                       throws Exception
        Specified by:
        savepoint in interface org.apache.flink.runtime.state.CheckpointableKeyedStateBackend<K>
        Throws:
        Exception