K
- The type of the key.N
- The type of the namespace.V
- The type of values kept internally in state.S
- The type of State
.public abstract class AbstractRocksDBState<K,N,V,S extends State> 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 RocksDBStateBackend
manages and checkpoints.
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 V |
defaultValue |
protected DataOutputView |
keySerializationDataOutputView |
protected ByteArrayOutputStreamWithPos |
keySerializationStream |
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.
|
void |
setCurrentNamespace(N namespace)
Sets the current namespace, which will be used when using the state access methods.
|
protected void |
writeCurrentKeyWithGroupAndNamespace() |
protected void |
writeKeyWithGroupAndNamespace(int keyGroup,
K key,
N namespace,
ByteArrayOutputStreamWithPos keySerializationStream,
DataOutputView keySerializationDataOutputView) |
protected void |
writeKeyWithGroupAndNamespace(int keyGroup,
K key,
TypeSerializer<K> keySerializer,
N namespace,
TypeSerializer<N> namespaceSerializer,
ByteArrayOutputStreamWithPos keySerializationStream,
DataOutputView keySerializationDataOutputView) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getKeySerializer, getNamespaceSerializer, getValueSerializer
protected RocksDBKeyedStateBackend<K> backend
protected org.rocksdb.ColumnFamilyHandle columnFamily
protected final V defaultValue
protected final org.rocksdb.WriteOptions writeOptions
protected final ByteArrayOutputStreamWithPos keySerializationStream
protected final DataOutputView keySerializationDataOutputView
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 forwardedprotected void writeCurrentKeyWithGroupAndNamespace() throws IOException
IOException
protected void writeKeyWithGroupAndNamespace(int keyGroup, K key, N namespace, ByteArrayOutputStreamWithPos keySerializationStream, DataOutputView keySerializationDataOutputView) throws IOException
IOException
protected void writeKeyWithGroupAndNamespace(int keyGroup, K key, TypeSerializer<K> keySerializer, N namespace, TypeSerializer<N> namespaceSerializer, ByteArrayOutputStreamWithPos keySerializationStream, DataOutputView keySerializationDataOutputView) throws IOException
IOException
protected V getDefaultValue()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.