Class AbstractRocksDBState<K,​N,​V>

  • Type Parameters:
    K - The type of the key.
    N - The type of the namespace.
    V - The type of values kept internally in state.
    All Implemented Interfaces:
    org.apache.flink.api.common.state.State, org.apache.flink.runtime.state.internal.InternalKvState<K,​N,​V>

    public abstract class AbstractRocksDBState<K,​N,​V>
    extends Object
    implements org.apache.flink.runtime.state.internal.InternalKvState<K,​N,​V>, org.apache.flink.api.common.state.State
    Base class for State implementations that store state in a RocksDB database.

    State is not stored in this class but in the RocksDB instance that the EmbeddedRocksDBStateBackend manages and checkpoints.

    • Nested Class Summary

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

        org.apache.flink.runtime.state.internal.InternalKvState.StateIncrementalVisitor<K extends Object,​N extends Object,​V extends Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected RocksDBKeyedStateBackend<K> backend
      Backend that holds the actual RocksDB instance where we store state.
      protected org.rocksdb.ColumnFamilyHandle columnFamily
      The column family of this particular instance of state.
      protected org.apache.flink.core.memory.DataInputDeserializer dataInputView  
      protected org.apache.flink.core.memory.DataOutputSerializer dataOutputView  
      protected V defaultValue  
      protected org.rocksdb.WriteOptions writeOptions  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractRocksDBState​(org.rocksdb.ColumnFamilyHandle columnFamily, org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer, org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer, V defaultValue, RocksDBKeyedStateBackend<K> backend)
      Creates a new RocksDB backed state.
    • Field Detail

      • backend

        protected RocksDBKeyedStateBackend<K> backend
        Backend that holds the actual RocksDB instance where we store state.
      • columnFamily

        protected org.rocksdb.ColumnFamilyHandle columnFamily
        The column family of this particular instance of state.
      • defaultValue

        protected V defaultValue
      • writeOptions

        protected final org.rocksdb.WriteOptions writeOptions
      • dataOutputView

        protected final org.apache.flink.core.memory.DataOutputSerializer dataOutputView
      • dataInputView

        protected final org.apache.flink.core.memory.DataInputDeserializer dataInputView
    • Constructor Detail

      • AbstractRocksDBState

        protected AbstractRocksDBState​(org.rocksdb.ColumnFamilyHandle columnFamily,
                                       org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer,
                                       org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer,
                                       V defaultValue,
                                       RocksDBKeyedStateBackend<K> backend)
        Creates a new RocksDB backed state.
        Parameters:
        columnFamily - The RocksDB column family that this state is associated to.
        namespaceSerializer - The serializer for the namespace.
        valueSerializer - The serializer for the state.
        defaultValue - The default value for the state.
        backend - The backend for which this state is bind to.
    • Method Detail

      • clear

        public void clear()
        Specified by:
        clear in interface org.apache.flink.api.common.state.State
      • setCurrentNamespace

        public void setCurrentNamespace​(N namespace)
        Specified by:
        setCurrentNamespace in interface org.apache.flink.runtime.state.internal.InternalKvState<K,​N,​V>
      • getSerializedValue

        public 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
        Specified by:
        getSerializedValue in interface org.apache.flink.runtime.state.internal.InternalKvState<K,​N,​V>
        Throws:
        Exception
      • migrateSerializedValue

        public void migrateSerializedValue​(org.apache.flink.core.memory.DataInputDeserializer serializedOldValueInput,
                                           org.apache.flink.core.memory.DataOutputSerializer serializedMigratedValueOutput,
                                           org.apache.flink.api.common.typeutils.TypeSerializer<V> priorSerializer,
                                           org.apache.flink.api.common.typeutils.TypeSerializer<V> newSerializer)
                                    throws org.apache.flink.util.StateMigrationException
        Throws:
        org.apache.flink.util.StateMigrationException
      • getDefaultValue

        protected V getDefaultValue()
      • setNamespaceSerializer

        protected AbstractRocksDBState<K,​N,​V> setNamespaceSerializer​(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)
      • setValueSerializer

        protected AbstractRocksDBState<K,​N,​V> setValueSerializer​(org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer)
      • getStateIncrementalVisitor

        public org.apache.flink.runtime.state.internal.InternalKvState.StateIncrementalVisitor<K,​N,​V> getStateIncrementalVisitor​(int recommendedMaxNumberOfReturnedRecords)
        Specified by:
        getStateIncrementalVisitor in interface org.apache.flink.runtime.state.internal.InternalKvState<K,​N,​V>