K
- type of keyN
- type of namespaceS
- type of statepublic abstract class StateMap<K,N,S> extends Object implements Iterable<StateEntry<K,N,S>>
Constructor and Description |
---|
StateMap() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
containsKey(K key,
N namespace)
Returns whether this map contains the specified key/namespace composite key.
|
abstract S |
get(K key,
N namespace)
Returns the state for the composite of active key and given namespace.
|
abstract Stream<K> |
getKeys(N namespace) |
abstract InternalKvState.StateIncrementalVisitor<K,N,S> |
getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords) |
boolean |
isEmpty()
Returns whether this
StateMap is empty. |
abstract void |
put(K key,
N namespace,
S state)
Maps the specified key/namespace composite key to the specified value.
|
abstract 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 . |
abstract void |
remove(K key,
N namespace)
Removes the mapping for the composite of active key and given namespace.
|
abstract 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.
|
abstract int |
size()
Returns the total number of entries in this
StateMap . |
abstract int |
sizeOfNamespace(Object namespace) |
abstract StateMapSnapshot<K,N,S,? extends StateMap<K,N,S>> |
stateSnapshot()
Creates a snapshot of this
StateMap , to be written in checkpointing. |
abstract <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, iterator, spliterator
public boolean isEmpty()
StateMap
is empty.public abstract int size()
StateMap
.StateMap
.public abstract S get(K key, N namespace)
key
- the key. Not null.namespace
- the namespace. Not null.null
if no mapping for the specified key is found.public abstract boolean containsKey(K key, N namespace)
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 abstract void put(K key, N namespace, S state)
#putAndGetOld(K, N, S)
(key, Namespace, State) when the caller is not
interested in the old state.key
- the key. Not null.namespace
- the namespace. Not null.state
- the state. Can be null.public abstract S putAndGetOld(K key, N namespace, S state)
key
- the key. Not null.namespace
- the namespace. Not null.state
- the state. Can be null.null
if there was
no such mapping.public abstract void remove(K key, N namespace)
#removeAndGetOld(K, N)
when the caller is not interested in the old
state.key
- the key of the mapping to remove. Not null.namespace
- the namespace of the mapping to remove. Not null.public abstract S removeAndGetOld(K key, N namespace)
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 abstract <T> void transform(K key, N namespace, T value, StateTransformationFunction<S,T> transformation) throws Exception
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.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 abstract InternalKvState.StateIncrementalVisitor<K,N,S> getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)
@Nonnull public abstract StateMapSnapshot<K,N,S,? extends StateMap<K,N,S>> stateSnapshot()
StateMap
, to be written in checkpointing. Users should
call releaseSnapshot(StateMapSnapshot)
after using the returned object.StateMap
, for checkpointing.public void releaseSnapshot(StateMapSnapshot<K,N,S,? extends StateMap<K,N,S>> snapshotToRelease)
StateMap
. This method should be called once a snapshot
is no more needed.snapshotToRelease
- the snapshot to release, which was previously created by this state
map.@VisibleForTesting public abstract int sizeOfNamespace(Object namespace)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.