K
- The type of the key.N
- The type of the namespace.S
- The type of State
.SD
- The type of StateDescriptor
.public abstract class AbstractRocksDBState<K,N,S extends State,SD extends StateDescriptor<S,V>,V> extends Object implements KvState<N>, 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 DataOutputView |
keySerializationDataOutputView |
protected ByteArrayOutputStreamWithPos |
keySerializationStream |
protected SD |
stateDesc
State descriptor from which to create this state instance
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractRocksDBState(org.rocksdb.ColumnFamilyHandle columnFamily,
TypeSerializer<N> namespaceSerializer,
SD stateDesc,
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.
|
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace)
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 RocksDBKeyedStateBackend<K> backend
protected org.rocksdb.ColumnFamilyHandle columnFamily
protected final SD extends StateDescriptor<S,V> stateDesc
protected final ByteArrayOutputStreamWithPos keySerializationStream
protected final DataOutputView keySerializationDataOutputView
protected AbstractRocksDBState(org.rocksdb.ColumnFamilyHandle columnFamily, TypeSerializer<N> namespaceSerializer, SD stateDesc, RocksDBKeyedStateBackend<K> backend)
namespaceSerializer
- The serializer for the namespace.public void clear()
State
public void setCurrentNamespace(N namespace)
KvState
setCurrentNamespace
in interface KvState<N>
namespace
- The namespace.public byte[] getSerializedValue(byte[] serializedKeyAndNamespace) throws Exception
KvState
If no value is associated with key and namespace, null
is returned.
getSerializedValue
in interface KvState<N>
serializedKeyAndNamespace
- Serialized key and namespacenull
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
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.