K
- type of keyN
- type of namespaceS
- type of statepublic final class CopyOnWriteSkipListStateMap<K,N,S> extends StateMap<K,N,S> implements AutoCloseable
Constructor and Description |
---|
CopyOnWriteSkipListStateMap(TypeSerializer<K> keySerializer,
TypeSerializer<N> namespaceSerializer,
TypeSerializer<S> stateSerializer,
Allocator spaceAllocator,
int numKeysToDeleteOneTime,
float logicalRemovedKeysRatio) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
containsKey(K key,
N namespace)
Returns whether this map contains the specified key/namespace composite key.
|
S |
get(K key,
N namespace)
Returns the state for the composite of active key and given namespace.
|
Stream<K> |
getKeys(N namespace) |
int |
getRequestCount() |
InternalKvState.StateIncrementalVisitor<K,N,S> |
getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords) |
Iterator<StateEntry<K,N,S>> |
iterator() |
void |
put(K key,
N namespace,
S state)
Maps the specified key/namespace composite key to the specified value.
|
S |
putAndGetOld(K key,
N namespace,
S state)
Maps the composite of active key and given namespace to the specified state.
|
void |
releaseSnapshot(StateMapSnapshot<K,N,S,? extends StateMap<K,N,S>> snapshotToRelease)
Releases a snapshot for this
StateMap . |
void |
remove(K key,
N namespace)
Removes the mapping for the composite of active key and given namespace.
|
S |
removeAndGetOld(K key,
N namespace)
Removes the mapping for the composite of active key and given namespace, returning the state
that was found under the entry.
|
int |
size()
Returns the total number of entries in this
StateMap . |
int |
sizeOfNamespace(Object namespace) |
CopyOnWriteSkipListStateMapSnapshot<K,N,S> |
stateSnapshot()
Creates a snapshot of this
StateMap , to be written in checkpointing. |
<T> void |
transform(K key,
N namespace,
T value,
StateTransformationFunction<S,T> transformation)
Applies the given
StateTransformationFunction to the state (1st input argument),
using the given value as second input argument. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public CopyOnWriteSkipListStateMap(@Nonnull TypeSerializer<K> keySerializer, @Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull TypeSerializer<S> stateSerializer, @Nonnull Allocator spaceAllocator, int numKeysToDeleteOneTime, float logicalRemovedKeysRatio)
public int size()
StateMap
StateMap
.public int getRequestCount()
public S get(K key, N namespace)
StateMap
public boolean containsKey(K key, N namespace)
StateMap
containsKey
in class StateMap<K,N,S>
key
- the key in the composite key to search for. Not null.namespace
- the namespace in the composite key to search for. Not null.true
if this map contains the specified key/namespace composite key, false
otherwise.public void put(K key, N namespace, S state)
StateMap
#putAndGetOld(K, N, S)
(key, Namespace, State) when the caller is not
interested in the old state.public S putAndGetOld(K key, N namespace, S state)
StateMap
putAndGetOld
in class StateMap<K,N,S>
key
- the key. Not null.namespace
- the namespace. Not null.state
- the state. Can be null.null
if there was
no such mapping.public void remove(K key, N namespace)
StateMap
#removeAndGetOld(K, N)
when the caller is not interested in the old
state.public S removeAndGetOld(K key, N namespace)
StateMap
removeAndGetOld
in class StateMap<K,N,S>
key
- the key of the mapping to remove. Not null.namespace
- the namespace of the mapping to remove. Not null.null
if no mapping for the specified key
was found.public <T> void transform(K key, N namespace, T value, StateTransformationFunction<S,T> transformation) throws Exception
StateMap
StateTransformationFunction
to the state (1st input argument),
using the given value as second input argument. The result of StateTransformationFunction.apply(Object, Object)
is then stored as the new state. This
function is basically an optimization for get-update-put pattern.transform
in class StateMap<K,N,S>
key
- the key. Not null.namespace
- the namespace. Not null.value
- the value to use in transforming the state. Can be null.transformation
- the transformation function.Exception
- if some exception happens in the transformation function.public int sizeOfNamespace(Object namespace)
sizeOfNamespace
in class StateMap<K,N,S>
public InternalKvState.StateIncrementalVisitor<K,N,S> getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)
getStateIncrementalVisitor
in class StateMap<K,N,S>
@Nonnull public CopyOnWriteSkipListStateMapSnapshot<K,N,S> stateSnapshot()
StateMap
StateMap
, to be written in checkpointing. Users should
call StateMap.releaseSnapshot(StateMapSnapshot)
after using the returned object.public void releaseSnapshot(StateMapSnapshot<K,N,S,? extends StateMap<K,N,S>> snapshotToRelease)
StateMap
StateMap
. This method should be called once a snapshot
is no more needed.releaseSnapshot
in class StateMap<K,N,S>
snapshotToRelease
- the snapshot to release, which was previously created by this state
map.public void close()
close
in interface AutoCloseable
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.