Search in sources :

Example 1 with StateSnapshotTransformFactory

use of org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory in project flink by apache.

the class MockKeyedStateBackend method createInternalState.

@Override
@SuppressWarnings("unchecked")
@Nonnull
public <N, SV, SEV, S extends State, IS extends S> IS createInternalState(@Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull StateDescriptor<S, SV> stateDesc, @Nonnull StateSnapshotTransformFactory<SEV> snapshotTransformFactory) throws Exception {
    StateFactory stateFactory = STATE_FACTORIES.get(stateDesc.getType());
    if (stateFactory == null) {
        String message = String.format("State %s is not supported by %s", stateDesc.getClass(), TtlStateFactory.class);
        throw new FlinkRuntimeException(message);
    }
    IS state = stateFactory.createInternalState(namespaceSerializer, stateDesc);
    stateSnapshotFilters.put(stateDesc.getName(), (StateSnapshotTransformer<Object>) getStateSnapshotTransformer(stateDesc, snapshotTransformFactory));
    ((MockInternalKvState<K, N, SV>) state).values = () -> stateValues.computeIfAbsent(stateDesc.getName(), n -> new HashMap<>()).computeIfAbsent(getCurrentKey(), k -> new HashMap<>());
    return state;
}
Also used : Tuple2(org.apache.flink.api.java.tuple.Tuple2) SharedStateRegistry(org.apache.flink.runtime.state.SharedStateRegistry) StateHandleID(org.apache.flink.runtime.state.StateHandleID) FutureTask(java.util.concurrent.FutureTask) HashMap(java.util.HashMap) MapStateDescriptor(org.apache.flink.api.common.state.MapStateDescriptor) KeyExtractorFunction(org.apache.flink.runtime.state.KeyExtractorFunction) InternalKeyContext(org.apache.flink.runtime.state.heap.InternalKeyContext) ArrayList(java.util.ArrayList) StateSnapshotTransformers(org.apache.flink.runtime.state.StateSnapshotTransformers) CloseableRegistry(org.apache.flink.core.fs.CloseableRegistry) HeapPriorityQueueSet(org.apache.flink.runtime.state.heap.HeapPriorityQueueSet) Map(java.util.Map) StateSnapshotTransformer(org.apache.flink.runtime.state.StateSnapshotTransformer) ListStateDescriptor(org.apache.flink.api.common.state.ListStateDescriptor) KeyGroupedInternalPriorityQueue(org.apache.flink.runtime.state.KeyGroupedInternalPriorityQueue) Nonnull(javax.annotation.Nonnull) LatencyTrackingStateConfig(org.apache.flink.runtime.state.metrics.LatencyTrackingStateConfig) State(org.apache.flink.api.common.state.State) RunnableFuture(java.util.concurrent.RunnableFuture) KeyGroupRange(org.apache.flink.runtime.state.KeyGroupRange) SnapshotResult(org.apache.flink.runtime.state.SnapshotResult) TaskKvStateRegistry(org.apache.flink.runtime.query.TaskKvStateRegistry) TypeSerializer(org.apache.flink.api.common.typeutils.TypeSerializer) StateDescriptor(org.apache.flink.api.common.state.StateDescriptor) Keyed(org.apache.flink.runtime.state.Keyed) StateSnapshotTransformFactory(org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) KeyedStateHandle(org.apache.flink.runtime.state.KeyedStateHandle) CheckpointOptions(org.apache.flink.runtime.checkpoint.CheckpointOptions) Collectors(java.util.stream.Collectors) HeapPriorityQueueElement(org.apache.flink.runtime.state.heap.HeapPriorityQueueElement) Serializable(java.io.Serializable) TtlTimeProvider(org.apache.flink.runtime.state.ttl.TtlTimeProvider) List(java.util.List) PriorityComparator(org.apache.flink.runtime.state.PriorityComparator) Stream(java.util.stream.Stream) PriorityComparable(org.apache.flink.runtime.state.PriorityComparable) AbstractKeyedStateBackend(org.apache.flink.runtime.state.AbstractKeyedStateBackend) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) Optional(java.util.Optional) CheckpointStreamFactory(org.apache.flink.runtime.state.CheckpointStreamFactory) SavepointResources(org.apache.flink.runtime.state.SavepointResources) TtlStateFactory(org.apache.flink.runtime.state.ttl.TtlStateFactory) TtlStateFactory(org.apache.flink.runtime.state.ttl.TtlStateFactory) HashMap(java.util.HashMap) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) Nonnull(javax.annotation.Nonnull)

Aggregations

Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 FutureTask (java.util.concurrent.FutureTask)1 RunnableFuture (java.util.concurrent.RunnableFuture)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 ListStateDescriptor (org.apache.flink.api.common.state.ListStateDescriptor)1 MapStateDescriptor (org.apache.flink.api.common.state.MapStateDescriptor)1 State (org.apache.flink.api.common.state.State)1 StateDescriptor (org.apache.flink.api.common.state.StateDescriptor)1 TypeSerializer (org.apache.flink.api.common.typeutils.TypeSerializer)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 CloseableRegistry (org.apache.flink.core.fs.CloseableRegistry)1 CheckpointOptions (org.apache.flink.runtime.checkpoint.CheckpointOptions)1