K
- The type of the key.N
- The type of the namespace.UK
- The type of the keys in the state.UV
- The type of the values in the state.public class HeapMapState<K,N,UK,UV> extends AbstractHeapState<K,N,Map<UK,UV>,MapState<UK,UV>> implements InternalMapState<K,N,UK,UV>
MapState
that is snapshotted into files.currentNamespace, keySerializer, namespaceSerializer, stateTable, valueSerializer
Constructor and Description |
---|
HeapMapState(StateTable<K,N,Map<UK,UV>> stateTable,
TypeSerializer<K> keySerializer,
TypeSerializer<Map<UK,UV>> valueSerializer,
TypeSerializer<N> namespaceSerializer,
Map<UK,UV> defaultValue)
Creates a new key/value state for the given hash map of key/value pairs.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(UK userKey)
Returns whether there exists the given mapping.
|
Iterable<Map.Entry<UK,UV>> |
entries()
Returns all the mappings in the state.
|
UV |
get(UK userKey)
Returns the current value associated with the given key.
|
TypeSerializer<K> |
getKeySerializer()
Returns the
TypeSerializer for the type of key this state is associated to. |
TypeSerializer<N> |
getNamespaceSerializer()
Returns the
TypeSerializer for the type of namespace this state is associated to. |
byte[] |
getSerializedValue(byte[] serializedKeyAndNamespace,
TypeSerializer<K> safeKeySerializer,
TypeSerializer<N> safeNamespaceSerializer,
TypeSerializer<Map<UK,UV>> safeValueSerializer)
Returns the serialized value for the given key and namespace.
|
TypeSerializer<Map<UK,UV>> |
getValueSerializer()
Returns the
TypeSerializer for the type of value this state holds. |
Iterator<Map.Entry<UK,UV>> |
iterator()
Iterates over all the mappings in the state.
|
Iterable<UK> |
keys()
Returns all the keys in the state.
|
void |
put(UK userKey,
UV userValue)
Associates a new value with the given key.
|
void |
putAll(Map<UK,UV> value)
Copies all of the mappings from the given map into the state.
|
void |
remove(UK userKey)
Deletes the mapping of the given key.
|
Iterable<UV> |
values()
Returns all the values in the state.
|
clear, getDefaultValue, getStateTable, setCurrentNamespace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setCurrentNamespace
public HeapMapState(StateTable<K,N,Map<UK,UV>> stateTable, TypeSerializer<K> keySerializer, TypeSerializer<Map<UK,UV>> valueSerializer, TypeSerializer<N> namespaceSerializer, Map<UK,UV> defaultValue)
stateTable
- The state table for which this state is associated to.keySerializer
- The serializer for the keys.valueSerializer
- The serializer for the state.namespaceSerializer
- The serializer for the namespace.defaultValue
- The default value for the state.public TypeSerializer<K> getKeySerializer()
InternalKvState
TypeSerializer
for the type of key this state is associated to.getKeySerializer
in interface InternalKvState<K,N,Map<UK,UV>>
public TypeSerializer<N> getNamespaceSerializer()
InternalKvState
TypeSerializer
for the type of namespace this state is associated to.getNamespaceSerializer
in interface InternalKvState<K,N,Map<UK,UV>>
public TypeSerializer<Map<UK,UV>> getValueSerializer()
InternalKvState
TypeSerializer
for the type of value this state holds.getValueSerializer
in interface InternalKvState<K,N,Map<UK,UV>>
public UV get(UK userKey)
MapState
public void put(UK userKey, UV userValue)
MapState
public void putAll(Map<UK,UV> value)
MapState
public void remove(UK userKey)
MapState
public boolean contains(UK userKey)
MapState
public Iterable<Map.Entry<UK,UV>> entries()
MapState
public Iterable<UK> keys()
MapState
public Iterable<UV> values()
MapState
public Iterator<Map.Entry<UK,UV>> iterator()
MapState
public byte[] getSerializedValue(byte[] serializedKeyAndNamespace, TypeSerializer<K> safeKeySerializer, TypeSerializer<N> safeNamespaceSerializer, TypeSerializer<Map<UK,UV>> 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,Map<UK,UV>>
getSerializedValue
in class AbstractHeapState<K,N,Map<UK,UV>,MapState<UK,UV>>
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 forwardedCopyright © 2014–2019 The Apache Software Foundation. All rights reserved.