K
- The type of the key.N
- The type of the namespace.V
- The type of values kept internally in state.public abstract class AbstractRocksDBState<K,N,V> extends Object implements InternalKvState<K,N,V>, State
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.
InternalKvState.StateIncrementalVisitor<K,N,V>
Modifier and Type | Field and 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 DataInputDeserializer |
dataInputView |
protected DataOutputSerializer |
dataOutputView |
protected V |
defaultValue |
protected org.rocksdb.WriteOptions |
writeOptions |
Modifier | Constructor and Description |
---|---|
protected |
AbstractRocksDBState(org.rocksdb.ColumnFamilyHandle columnFamily,
TypeSerializer<N> namespaceSerializer,
TypeSerializer<V> valueSerializer,
V defaultValue,
RocksDBKeyedStateBackend<K> backend)
Creates a new RocksDB backed state.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes the value mapped under the current key.
|
protected V |
getDefaultValue() |
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace,
TypeSerializer<K> safeKeySerializer,
TypeSerializer<N> safeNamespaceSerializer,
TypeSerializer<V> safeValueSerializer)
Returns the serialized value for the given key and namespace.
|
InternalKvState.StateIncrementalVisitor<K,N,V> |
getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)
Get global visitor of state entries.
|
void |
migrateSerializedValue(DataInputDeserializer serializedOldValueInput,
DataOutputSerializer serializedMigratedValueOutput,
TypeSerializer<V> priorSerializer,
TypeSerializer<V> newSerializer) |
void |
setCurrentNamespace(N namespace)
Sets the current namespace, which will be used when using the state access methods.
|
protected AbstractRocksDBState<K,N,V> |
setDefaultValue(V defaultValue) |
protected AbstractRocksDBState<K,N,V> |
setNamespaceSerializer(TypeSerializer<N> namespaceSerializer) |
protected AbstractRocksDBState<K,N,V> |
setValueSerializer(TypeSerializer<V> valueSerializer) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getKeySerializer, getNamespaceSerializer, getValueSerializer
protected RocksDBKeyedStateBackend<K> backend
protected org.rocksdb.ColumnFamilyHandle columnFamily
protected V defaultValue
protected final org.rocksdb.WriteOptions writeOptions
protected final DataOutputSerializer dataOutputView
protected final DataInputDeserializer dataInputView
protected AbstractRocksDBState(org.rocksdb.ColumnFamilyHandle columnFamily, TypeSerializer<N> namespaceSerializer, TypeSerializer<V> valueSerializer, V defaultValue, RocksDBKeyedStateBackend<K> backend)
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.public void clear()
State
public void setCurrentNamespace(N namespace)
InternalKvState
setCurrentNamespace
in interface InternalKvState<K,N,V>
namespace
- The namespace.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace, TypeSerializer<K> safeKeySerializer, TypeSerializer<N> safeNamespaceSerializer, TypeSerializer<V> safeValueSerializer) throws Exception
InternalKvState
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.
getSerializedValue
in interface InternalKvState<K,N,V>
serializedKeyAndNamespace
- Serialized key and namespacesafeKeySerializer
- A key serializer which is safe to be used even in multi-threaded
contextsafeNamespaceSerializer
- A namespace serializer which is safe to be used even in
multi-threaded contextsafeValueSerializer
- A value serializer which is safe to be used even in multi-threaded
contextnull
if no value is associated with the key and
namespace.Exception
- Exceptions during serialization are forwardedpublic void migrateSerializedValue(DataInputDeserializer serializedOldValueInput, DataOutputSerializer serializedMigratedValueOutput, TypeSerializer<V> priorSerializer, TypeSerializer<V> newSerializer) throws StateMigrationException
StateMigrationException
protected V getDefaultValue()
protected AbstractRocksDBState<K,N,V> setNamespaceSerializer(TypeSerializer<N> namespaceSerializer)
protected AbstractRocksDBState<K,N,V> setValueSerializer(TypeSerializer<V> valueSerializer)
protected AbstractRocksDBState<K,N,V> setDefaultValue(V defaultValue)
public InternalKvState.StateIncrementalVisitor<K,N,V> getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)
InternalKvState
getStateIncrementalVisitor
in interface InternalKvState<K,N,V>
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.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.