Class DefaultStateManager

  • All Implemented Interfaces:
    org.apache.flink.datastream.api.context.StateManager

    public class DefaultStateManager
    extends Object
    implements org.apache.flink.datastream.api.context.StateManager
    The default implementation of StateManager. This class supports eagerly set and reset the current key.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.flink.streaming.api.operators.StreamingRuntimeContext operatorContext  
      protected org.apache.flink.api.common.state.OperatorStateStore operatorStateStore  
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultStateManager​(java.util.function.Supplier<Object> currentKeySupplier, java.util.function.Consumer<Object> currentKeySetter, org.apache.flink.streaming.api.operators.StreamingRuntimeContext operatorContext, org.apache.flink.api.common.state.OperatorStateStore operatorStateStore)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void executeInKeyContext​(Runnable runnable, Object key)
      This method should be used to run a block of code with a specific key context.
      <K> K getCurrentKey()  
      <IN,​ACC,​OUT>
      Optional<org.apache.flink.api.common.state.AggregatingState<IN,​OUT>>
      getState​(org.apache.flink.api.common.state.AggregatingStateDeclaration<IN,​ACC,​OUT> stateDeclaration)  
      <K,​V>
      Optional<org.apache.flink.api.common.state.BroadcastState<K,​V>>
      getState​(org.apache.flink.api.common.state.BroadcastStateDeclaration<K,​V> stateDeclaration)  
      <T> Optional<org.apache.flink.api.common.state.ListState<T>> getState​(org.apache.flink.api.common.state.ListStateDeclaration<T> stateDeclaration)  
      <K,​V>
      Optional<org.apache.flink.api.common.state.MapState<K,​V>>
      getState​(org.apache.flink.api.common.state.MapStateDeclaration<K,​V> stateDeclaration)  
      <T> Optional<org.apache.flink.api.common.state.ReducingState<T>> getState​(org.apache.flink.api.common.state.ReducingStateDeclaration<T> stateDeclaration)  
      <T> Optional<org.apache.flink.api.common.state.ValueState<T>> getState​(org.apache.flink.api.common.state.ValueStateDeclaration<T> stateDeclaration)  
    • Field Detail

      • operatorContext

        protected final org.apache.flink.streaming.api.operators.StreamingRuntimeContext operatorContext
      • operatorStateStore

        protected final org.apache.flink.api.common.state.OperatorStateStore operatorStateStore
    • Constructor Detail

      • DefaultStateManager

        public DefaultStateManager​(java.util.function.Supplier<Object> currentKeySupplier,
                                   java.util.function.Consumer<Object> currentKeySetter,
                                   org.apache.flink.streaming.api.operators.StreamingRuntimeContext operatorContext,
                                   org.apache.flink.api.common.state.OperatorStateStore operatorStateStore)
    • Method Detail

      • getCurrentKey

        public <K> K getCurrentKey()
        Specified by:
        getCurrentKey in interface org.apache.flink.datastream.api.context.StateManager
      • getState

        public <T> Optional<org.apache.flink.api.common.state.ValueState<T>> getState​(org.apache.flink.api.common.state.ValueStateDeclaration<T> stateDeclaration)
                                                                               throws Exception
        Specified by:
        getState in interface org.apache.flink.datastream.api.context.StateManager
        Throws:
        Exception
      • getState

        public <T> Optional<org.apache.flink.api.common.state.ListState<T>> getState​(org.apache.flink.api.common.state.ListStateDeclaration<T> stateDeclaration)
                                                                              throws Exception
        Specified by:
        getState in interface org.apache.flink.datastream.api.context.StateManager
        Throws:
        Exception
      • getState

        public <K,​V> Optional<org.apache.flink.api.common.state.MapState<K,​V>> getState​(org.apache.flink.api.common.state.MapStateDeclaration<K,​V> stateDeclaration)
                                                                                             throws Exception
        Specified by:
        getState in interface org.apache.flink.datastream.api.context.StateManager
        Throws:
        Exception
      • getState

        public <T> Optional<org.apache.flink.api.common.state.ReducingState<T>> getState​(org.apache.flink.api.common.state.ReducingStateDeclaration<T> stateDeclaration)
                                                                                  throws Exception
        Specified by:
        getState in interface org.apache.flink.datastream.api.context.StateManager
        Throws:
        Exception
      • getState

        public <IN,​ACC,​OUT> Optional<org.apache.flink.api.common.state.AggregatingState<IN,​OUT>> getState​(org.apache.flink.api.common.state.AggregatingStateDeclaration<IN,​ACC,​OUT> stateDeclaration)
                                                                                                                     throws Exception
        Specified by:
        getState in interface org.apache.flink.datastream.api.context.StateManager
        Throws:
        Exception
      • getState

        public <K,​V> Optional<org.apache.flink.api.common.state.BroadcastState<K,​V>> getState​(org.apache.flink.api.common.state.BroadcastStateDeclaration<K,​V> stateDeclaration)
                                                                                                   throws Exception
        Specified by:
        getState in interface org.apache.flink.datastream.api.context.StateManager
        Throws:
        Exception
      • executeInKeyContext

        public void executeInKeyContext​(Runnable runnable,
                                        Object key)
        This method should be used to run a block of code with a specific key context. The original key must be reset after the block is executed.