K
- type of keyN
- type of namespaceS
- type of statepublic abstract class StateTable<K,N,S> extends Object
InternalKeyContext
.Modifier and Type | Field and Description |
---|---|
protected InternalKeyContext<K> |
keyContext
The key context view on the backend.
|
protected RegisteredKeyedBackendStateMetaInfo<N,S> |
metaInfo
Combined meta information such as name and serializers for this state
|
Constructor and Description |
---|
StateTable(InternalKeyContext<K> keyContext,
RegisteredKeyedBackendStateMetaInfo<N,S> metaInfo) |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
containsKey(N namespace)
Returns whether this table contains a mapping for the composite of active key and given namespace.
|
abstract S |
get(K key,
N namespace)
Returns the state for the composite of active key and given namespace.
|
abstract S |
get(N namespace)
Returns the state of the mapping for the composite of active key and given namespace.
|
abstract java.util.stream.Stream<K> |
getKeys(N namespace) |
RegisteredKeyedBackendStateMetaInfo<N,S> |
getMetaInfo() |
TypeSerializer<N> |
getNamespaceSerializer() |
TypeSerializer<S> |
getStateSerializer() |
boolean |
isEmpty()
Returns whether this
NestedMapsStateTable is empty. |
abstract void |
put(K key,
int keyGroup,
N namespace,
S state) |
abstract void |
put(N namespace,
S state)
Maps the composite of active key and given namespace to the specified state.
|
abstract S |
putAndGetOld(N namespace,
S state)
Maps the composite of active key and given namespace to the specified state.
|
abstract void |
remove(N namespace)
Removes the mapping for the composite of active key and given namespace.
|
abstract S |
removeAndGetOld(N namespace)
Removes the mapping for the composite of active key and given namespace, returning the state that was
found under the entry.
|
void |
setMetaInfo(RegisteredKeyedBackendStateMetaInfo<N,S> metaInfo) |
abstract int |
size()
Returns the total number of entries in this
NestedMapsStateTable . |
abstract int |
sizeOfNamespace(Object namespace) |
abstract <T> void |
transform(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. |
protected final InternalKeyContext<K> keyContext
protected RegisteredKeyedBackendStateMetaInfo<N,S> metaInfo
public StateTable(InternalKeyContext<K> keyContext, RegisteredKeyedBackendStateMetaInfo<N,S> metaInfo)
keyContext
- the key context provides the key scope for all put/get/delete operations.metaInfo
- the meta information, including the type serializer for state copy-on-write.public boolean isEmpty()
NestedMapsStateTable
is empty.true
if this NestedMapsStateTable
has no elements, false
otherwise.size()
public abstract int size()
NestedMapsStateTable
. This is the sum of both sub-tables.NestedMapsStateTable
.public abstract S get(N namespace)
namespace
- the namespace. Not null.null
if no mapping for the specified key is found.public abstract boolean containsKey(N namespace)
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(N namespace, S state)
#putAndGetOld(N, S)
(Namespace, State)} when the caller is not interested in the old state.namespace
- the namespace. Not null.state
- the state. Can be null.public abstract S putAndGetOld(N namespace, S state)
namespace
- the namespace. Not null.state
- the state. Can be null.null
if there was no such mapping.public abstract void remove(N namespace)
#removeAndGetOld(N)
when the caller is not interested in the old state.namespace
- the namespace of the mapping to remove. Not null.public abstract S removeAndGetOld(N namespace)
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(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.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 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 java.util.stream.Stream<K> getKeys(N namespace)
public TypeSerializer<S> getStateSerializer()
public TypeSerializer<N> getNamespaceSerializer()
public RegisteredKeyedBackendStateMetaInfo<N,S> getMetaInfo()
public void setMetaInfo(RegisteredKeyedBackendStateMetaInfo<N,S> metaInfo)
@VisibleForTesting public abstract int sizeOfNamespace(Object namespace)
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.