K
- type of key.N
- type of namespace.S
- type of state.@Internal public class NestedMapsStateTable<K,N,S> extends StateTable<K,N,S>
StateTable
uses nested HashMap
objects. It is also maintaining a partitioning
by key-group.
In contrast to CopyOnWriteStateTable
, this implementation does not support asynchronous snapshots. However,
it might have a better memory footprint for some use-cases, e.g. it is naturally de-duplicating namespace objects.
keyContext, metaInfo
构造器和说明 |
---|
NestedMapsStateTable(InternalKeyContext<K> keyContext,
RegisteredKeyValueStateBackendMetaInfo<N,S> metaInfo)
Creates a new
NestedMapsStateTable for the given key context and meta info. |
限定符和类型 | 方法和说明 |
---|---|
boolean |
containsKey(N namespace)
Returns whether this table contains a mapping for the composite of active key and given namespace.
|
S |
get(K key,
N namespace)
Returns the state for the composite of active key and given namespace.
|
S |
get(N namespace)
Returns the state of the mapping for the composite of active key and given namespace.
|
java.util.stream.Stream<K> |
getKeys(N namespace) |
Map<N,Map<K,S>>[] |
getState()
Returns the internal data structure.
|
InternalKvState.StateIncrementalVisitor<K,N,S> |
getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords) |
void |
put(K key,
int keyGroupIndex,
N namespace,
S value) |
void |
put(N namespace,
S state)
Maps the composite of active key and given namespace to the specified state.
|
S |
putAndGetOld(N namespace,
S state)
Maps the composite of active key and given namespace to the specified state.
|
void |
remove(N namespace)
Removes the mapping for the composite of active key and given namespace.
|
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.
|
int |
size()
Returns the total number of entries in this
StateTable . |
int |
sizeOfNamespace(Object namespace) |
org.apache.flink.runtime.state.heap.NestedMapsStateTable.NestedMapsStateTableSnapshot<K,N,S> |
stateSnapshot()
Returns a snapshot of the state.
|
<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. |
getMetaInfo, getNamespaceSerializer, getStateSerializer, isEmpty, keyGroupReader, setMetaInfo
public NestedMapsStateTable(InternalKeyContext<K> keyContext, RegisteredKeyValueStateBackendMetaInfo<N,S> metaInfo)
NestedMapsStateTable
for the given key context and meta info.keyContext
- the key context.metaInfo
- the meta information for this state table.@VisibleForTesting public Map<N,Map<K,S>>[] getState()
public int size()
StateTable
StateTable
. This is the sum of both sub-tables.size
在类中 StateTable<K,N,S>
StateTable
.public S get(N namespace)
StateTable
get
在类中 StateTable<K,N,S>
namespace
- the namespace. Not null.null
if no mapping for the specified key is found.public boolean containsKey(N namespace)
StateTable
containsKey
在类中 StateTable<K,N,S>
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(N namespace, S state)
StateTable
#putAndGetOld(N, S)
(Namespace, State)} when the caller is not interested in the old state.put
在类中 StateTable<K,N,S>
namespace
- the namespace. Not null.state
- the state. Can be null.public S putAndGetOld(N namespace, S state)
StateTable
putAndGetOld
在类中 StateTable<K,N,S>
namespace
- the namespace. Not null.state
- the state. Can be null.null
if there was no such mapping.public void remove(N namespace)
StateTable
#removeAndGetOld(N)
when the caller is not interested in the old state.remove
在类中 StateTable<K,N,S>
namespace
- the namespace of the mapping to remove. Not null.public S removeAndGetOld(N namespace)
StateTable
removeAndGetOld
在类中 StateTable<K,N,S>
namespace
- the namespace of the mapping to remove. Not null.null
if no mapping
for the specified key was found.public S get(K key, N namespace)
StateTable
get
在类中 StateTable<K,N,S>
key
- the key. Not null.namespace
- the namespace. Not null.null
if no mapping for the specified key is found.public java.util.stream.Stream<K> getKeys(N namespace)
getKeys
在类中 StateTable<K,N,S>
public InternalKvState.StateIncrementalVisitor<K,N,S> getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords)
getStateIncrementalVisitor
在类中 StateTable<K,N,S>
public int sizeOfNamespace(Object namespace)
sizeOfNamespace
在类中 StateTable<K,N,S>
public <T> void transform(N namespace, T value, StateTransformationFunction<S,T> transformation) throws Exception
StateTable
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.@Nonnull public org.apache.flink.runtime.state.heap.NestedMapsStateTable.NestedMapsStateTableSnapshot<K,N,S> stateSnapshot()
StateSnapshotRestore
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.