K
- The type of the key in the snapshot state.N
- The type of the namespace in the snapshot state.SV
- The type of the value in the snapshot state.public abstract class AbstractMemStateSnapshot<K,N,SV,S extends State,SD extends StateDescriptor<S,?>> extends Object implements KvStateSnapshot<K,N,S,SD,MemoryStateBackend>
MemValueState
for a checkpoint. The data is stored in a heap byte
array, in serialized form.Modifier and Type | Field and Description |
---|---|
protected TypeSerializer<K> |
keySerializer
Key Serializer
|
protected TypeSerializer<N> |
namespaceSerializer
Namespace Serializer
|
protected SD |
stateDesc
StateDescriptor, for sanity checks
|
protected TypeSerializer<SV> |
stateSerializer
Serializer for the state value
|
Constructor and Description |
---|
AbstractMemStateSnapshot(TypeSerializer<K> keySerializer,
TypeSerializer<N> namespaceSerializer,
TypeSerializer<SV> stateSerializer,
SD stateDesc,
byte[] data)
Creates a new heap memory state snapshot.
|
Modifier and Type | Method and Description |
---|---|
abstract KvState<K,N,S,SD,MemoryStateBackend> |
createMemState(HashMap<N,Map<K,SV>> stateMap) |
void |
discardState()
Discarding the heap state is a no-op.
|
long |
getStateSize()
Returns the size of the state in bytes.
|
KvState<K,N,S,SD,MemoryStateBackend> |
restoreState(MemoryStateBackend stateBackend,
TypeSerializer<K> keySerializer,
ClassLoader classLoader,
long recoveryTimestamp)
Loads the key/value state back from this snapshot.
|
protected final TypeSerializer<K> keySerializer
protected final TypeSerializer<N> namespaceSerializer
protected final TypeSerializer<SV> stateSerializer
protected final SD extends StateDescriptor<S,?> stateDesc
public AbstractMemStateSnapshot(TypeSerializer<K> keySerializer, TypeSerializer<N> namespaceSerializer, TypeSerializer<SV> stateSerializer, SD stateDesc, byte[] data)
keySerializer
- The serializer for the keys.namespaceSerializer
- The serializer for the namespace.stateSerializer
- The serializer for the elements in the state HashMapstateDesc
- The state identifierdata
- The serialized data of the state key/value pairspublic abstract KvState<K,N,S,SD,MemoryStateBackend> createMemState(HashMap<N,Map<K,SV>> stateMap)
public KvState<K,N,S,SD,MemoryStateBackend> restoreState(MemoryStateBackend stateBackend, TypeSerializer<K> keySerializer, ClassLoader classLoader, long recoveryTimestamp) throws Exception
KvStateSnapshot
restoreState
in interface KvStateSnapshot<K,N,S extends State,SD extends StateDescriptor<S,?>,MemoryStateBackend>
stateBackend
- The state backend that created this snapshot and can restore the key/value state
from this snapshot.keySerializer
- The serializer for the keys.classLoader
- The class loader for user-defined types.recoveryTimestamp
- The timestamp of the checkpoint we are recovering from.Exception
- Exceptions can occur during the state loading and are forwarded.public void discardState()
discardState
in interface KvStateSnapshot<K,N,S extends State,SD extends StateDescriptor<S,?>,MemoryStateBackend>
public long getStateSize()
KvStateSnapshot
If the the size is not known, return 0
.
getStateSize
in interface KvStateSnapshot<K,N,S extends State,SD extends StateDescriptor<S,?>,MemoryStateBackend>
Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.