Class AbstractRocksDBState<K,N,V>
- java.lang.Object
-
- org.apache.flink.contrib.streaming.state.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 forState
implementations that store state in a RocksDB database.State is not stored in this class but in the
RocksDB
instance that theEmbeddedRocksDBStateBackend
manages and checkpoints.
-
-
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
protected V
getDefaultValue()
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)
org.apache.flink.runtime.state.internal.InternalKvState.StateIncrementalVisitor<K,N,V>
getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)
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)
void
setCurrentNamespace(N namespace)
protected AbstractRocksDBState<K,N,V>
setDefaultValue(V defaultValue)
protected AbstractRocksDBState<K,N,V>
setNamespaceSerializer(org.apache.flink.api.common.typeutils.TypeSerializer<N> namespaceSerializer)
protected AbstractRocksDBState<K,N,V>
setValueSerializer(org.apache.flink.api.common.typeutils.TypeSerializer<V> valueSerializer)
-
-
-
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 interfaceorg.apache.flink.api.common.state.State
-
setCurrentNamespace
public void setCurrentNamespace(N namespace)
-
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
-
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)
-
setDefaultValue
protected AbstractRocksDBState<K,N,V> setDefaultValue(V defaultValue)
-
-