org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory Java Examples
The following examples show how to use
org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockKeyedStateBackend.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <SV, SEV> StateSnapshotTransformer<SV> getStateSnapshotTransformer( StateDescriptor<?, SV> stateDesc, StateSnapshotTransformFactory<SEV> snapshotTransformFactory) { Optional<StateSnapshotTransformer<SEV>> original = snapshotTransformFactory.createForDeserializedState(); if (original.isPresent()) { if (stateDesc instanceof ListStateDescriptor) { return (StateSnapshotTransformer<SV>) new StateSnapshotTransformers.ListStateSnapshotTransformer<>(original.get()); } else if (stateDesc instanceof MapStateDescriptor) { return (StateSnapshotTransformer<SV>) new StateSnapshotTransformers.MapStateSnapshotTransformer<>(original.get()); } else { return (StateSnapshotTransformer<SV>) original.get(); } } else { return null; } }
Example #2
Source File: MockKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@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.getClass()); 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; }
Example #3
Source File: MockKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <SV, SEV> StateSnapshotTransformer<SV> getStateSnapshotTransformer( StateDescriptor<?, SV> stateDesc, StateSnapshotTransformFactory<SEV> snapshotTransformFactory) { Optional<StateSnapshotTransformer<SEV>> original = snapshotTransformFactory.createForDeserializedState(); if (original.isPresent()) { if (stateDesc instanceof ListStateDescriptor) { return (StateSnapshotTransformer<SV>) new StateSnapshotTransformers.ListStateSnapshotTransformer<>(original.get()); } else if (stateDesc instanceof MapStateDescriptor) { return (StateSnapshotTransformer<SV>) new StateSnapshotTransformers.MapStateSnapshotTransformer<>(original.get()); } else { return (StateSnapshotTransformer<SV>) original.get(); } } else { return null; } }
Example #4
Source File: RocksDBKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@Override @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.getClass()); if (stateFactory == null) { String message = String.format("State %s is not supported by %s", stateDesc.getClass(), this.getClass()); throw new FlinkRuntimeException(message); } Tuple2<ColumnFamilyHandle, RegisteredKeyValueStateBackendMetaInfo<N, SV>> registerResult = tryRegisterKvStateInformation( stateDesc, namespaceSerializer, snapshotTransformFactory); return stateFactory.createState(stateDesc, registerResult, RocksDBKeyedStateBackend.this); }
Example #5
Source File: HeapKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@Override @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.getClass()); if (stateFactory == null) { String message = String.format("State %s is not supported by %s", stateDesc.getClass(), this.getClass()); throw new FlinkRuntimeException(message); } StateTable<K, N, SV> stateTable = tryRegisterStateTable( namespaceSerializer, stateDesc, getStateSnapshotTransformFactory(stateDesc, snapshotTransformFactory)); return stateFactory.createState(stateDesc, stateTable, getKeySerializer()); }
Example #6
Source File: MockKeyedStateBackend.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@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.getClass()); 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; }
Example #7
Source File: HeapKeyedStateBackend.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override @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.getClass()); if (stateFactory == null) { String message = String.format("State %s is not supported by %s", stateDesc.getClass(), this.getClass()); throw new FlinkRuntimeException(message); } StateTable<K, N, SV> stateTable = tryRegisterStateTable( namespaceSerializer, stateDesc, getStateSnapshotTransformFactory(stateDesc, snapshotTransformFactory)); return stateFactory.createState(stateDesc, stateTable, getKeySerializer()); }
Example #8
Source File: HeapKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@Override @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.getClass()); if (stateFactory == null) { String message = String.format("State %s is not supported by %s", stateDesc.getClass(), this.getClass()); throw new FlinkRuntimeException(message); } StateTable<K, N, SV> stateTable = tryRegisterStateTable( namespaceSerializer, stateDesc, getStateSnapshotTransformFactory(stateDesc, snapshotTransformFactory)); return stateFactory.createState(stateDesc, stateTable, getKeySerializer()); }
Example #9
Source File: RocksDBKeyedStateBackend.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override @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.getClass()); if (stateFactory == null) { String message = String.format("State %s is not supported by %s", stateDesc.getClass(), this.getClass()); throw new FlinkRuntimeException(message); } Tuple2<ColumnFamilyHandle, RegisteredKeyValueStateBackendMetaInfo<N, SV>> registerResult = tryRegisterKvStateInformation( stateDesc, namespaceSerializer, snapshotTransformFactory); return stateFactory.createState(stateDesc, registerResult, RocksDBKeyedStateBackend.this); }
Example #10
Source File: RocksDBKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@Override @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.getClass()); if (stateFactory == null) { String message = String.format("State %s is not supported by %s", stateDesc.getClass(), this.getClass()); throw new FlinkRuntimeException(message); } Tuple2<ColumnFamilyHandle, RegisteredKeyValueStateBackendMetaInfo<N, SV>> registerResult = tryRegisterKvStateInformation( stateDesc, namespaceSerializer, snapshotTransformFactory); return stateFactory.createState(stateDesc, registerResult, RocksDBKeyedStateBackend.this); }
Example #11
Source File: MockKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@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.getClass()); 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; }
Example #12
Source File: MockKeyedStateBackend.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <SV, SEV> StateSnapshotTransformer<SV> getStateSnapshotTransformer( StateDescriptor<?, SV> stateDesc, StateSnapshotTransformFactory<SEV> snapshotTransformFactory) { Optional<StateSnapshotTransformer<SEV>> original = snapshotTransformFactory.createForDeserializedState(); if (original.isPresent()) { if (stateDesc instanceof ListStateDescriptor) { return (StateSnapshotTransformer<SV>) new StateSnapshotTransformers.ListStateSnapshotTransformer<>(original.get()); } else if (stateDesc instanceof MapStateDescriptor) { return (StateSnapshotTransformer<SV>) new StateSnapshotTransformers.MapStateSnapshotTransformer<>(original.get()); } else { return (StateSnapshotTransformer<SV>) original.get(); } } else { return null; } }
Example #13
Source File: RegisteredKeyValueStateBackendMetaInfo.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public RegisteredKeyValueStateBackendMetaInfo( @Nonnull StateDescriptor.Type stateType, @Nonnull String name, @Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull TypeSerializer<S> stateSerializer, @Nonnull StateSnapshotTransformFactory<S> stateSnapshotTransformFactory) { this( stateType, name, StateSerializerProvider.fromNewRegisteredSerializer(namespaceSerializer), StateSerializerProvider.fromNewRegisteredSerializer(stateSerializer), stateSnapshotTransformFactory); }
Example #14
Source File: RocksDBSnapshotTransformFactoryAdaptor.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private RocksDBListStateSnapshotTransformFactory( StateSnapshotTransformFactory<SEV> snapshotTransformFactory, TypeSerializer<SEV> elementSerializer) { super(snapshotTransformFactory); this.elementSerializer = elementSerializer; }
Example #15
Source File: TtlStateFactory.java From flink with Apache License 2.0 | 5 votes |
private StateSnapshotTransformFactory<?> getSnapshotTransformFactory() { if (!ttlConfig.getCleanupStrategies().inFullSnapshot()) { return StateSnapshotTransformFactory.noTransform(); } else { return new TtlStateSnapshotTransformer.Factory<>(timeProvider, ttl); } }
Example #16
Source File: HeapKeyedStateBackend.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <SV, SEV> StateSnapshotTransformFactory<SV> getStateSnapshotTransformFactory( StateDescriptor<?, SV> stateDesc, StateSnapshotTransformFactory<SEV> snapshotTransformFactory) { if (stateDesc instanceof ListStateDescriptor) { return (StateSnapshotTransformFactory<SV>) new StateSnapshotTransformers.ListStateSnapshotTransformFactory<>(snapshotTransformFactory); } else if (stateDesc instanceof MapStateDescriptor) { return (StateSnapshotTransformFactory<SV>) new StateSnapshotTransformers.MapStateSnapshotTransformFactory<>(snapshotTransformFactory); } else { return (StateSnapshotTransformFactory<SV>) snapshotTransformFactory; } }
Example #17
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
public RegisteredKeyValueStateBackendMetaInfo( @Nonnull StateDescriptor.Type stateType, @Nonnull String name, @Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull TypeSerializer<S> stateSerializer) { this( stateType, name, StateSerializerProvider.fromNewRegisteredSerializer(namespaceSerializer), StateSerializerProvider.fromNewRegisteredSerializer(stateSerializer), StateSnapshotTransformFactory.noTransform()); }
Example #18
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
public RegisteredKeyValueStateBackendMetaInfo( @Nonnull StateDescriptor.Type stateType, @Nonnull String name, @Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull TypeSerializer<S> stateSerializer, @Nonnull StateSnapshotTransformFactory<S> stateSnapshotTransformFactory) { this( stateType, name, StateSerializerProvider.fromNewRegisteredSerializer(namespaceSerializer), StateSerializerProvider.fromNewRegisteredSerializer(stateSerializer), stateSnapshotTransformFactory); }
Example #19
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public RegisteredKeyValueStateBackendMetaInfo(@Nonnull StateMetaInfoSnapshot snapshot) { this( StateDescriptor.Type.valueOf(snapshot.getOption(StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE)), snapshot.getName(), StateSerializerProvider.fromPreviousSerializerSnapshot( (TypeSerializerSnapshot<N>) Preconditions.checkNotNull( snapshot.getTypeSerializerSnapshot(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER))), StateSerializerProvider.fromPreviousSerializerSnapshot( (TypeSerializerSnapshot<S>) Preconditions.checkNotNull( snapshot.getTypeSerializerSnapshot(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER))), StateSnapshotTransformFactory.noTransform()); Preconditions.checkState(StateMetaInfoSnapshot.BackendStateType.KEY_VALUE == snapshot.getBackendStateType()); }
Example #20
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
private RegisteredKeyValueStateBackendMetaInfo( @Nonnull StateDescriptor.Type stateType, @Nonnull String name, @Nonnull StateSerializerProvider<N> namespaceSerializerProvider, @Nonnull StateSerializerProvider<S> stateSerializerProvider, @Nonnull StateSnapshotTransformFactory<S> stateSnapshotTransformFactory) { super(name); this.stateType = stateType; this.namespaceSerializerProvider = namespaceSerializerProvider; this.stateSerializerProvider = stateSerializerProvider; this.stateSnapshotTransformFactory = stateSnapshotTransformFactory; }
Example #21
Source File: ReductionsTest.java From stateful-functions with Apache License 2.0 | 5 votes |
@Nonnull @Override 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) { throw new UnsupportedOperationException(); }
Example #22
Source File: ReductionsTest.java From flink-statefun with Apache License 2.0 | 5 votes |
@Nonnull @Override 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) { throw new UnsupportedOperationException(); }
Example #23
Source File: RocksDBSnapshotTransformFactoryAdaptor.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") static <SV, SEV> StateSnapshotTransformFactory<SV> wrapStateSnapshotTransformFactory( StateDescriptor<?, SV> stateDesc, StateSnapshotTransformFactory<SEV> snapshotTransformFactory, TypeSerializer<SV> stateSerializer) { if (stateDesc instanceof ListStateDescriptor) { TypeSerializer<SEV> elementSerializer = ((ListSerializer<SEV>) stateSerializer).getElementSerializer(); return new RocksDBListStateSnapshotTransformFactory<>(snapshotTransformFactory, elementSerializer); } else if (stateDesc instanceof MapStateDescriptor) { return new RocksDBMapStateSnapshotTransformFactory<>(snapshotTransformFactory); } else { return new RocksDBValueStateSnapshotTransformFactory<>(snapshotTransformFactory); } }
Example #24
Source File: RocksDBSnapshotTransformFactoryAdaptor.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private RocksDBListStateSnapshotTransformFactory( StateSnapshotTransformFactory<SEV> snapshotTransformFactory, TypeSerializer<SEV> elementSerializer) { super(snapshotTransformFactory); this.elementSerializer = elementSerializer; }
Example #25
Source File: HeapKeyedStateBackend.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <SV, SEV> StateSnapshotTransformFactory<SV> getStateSnapshotTransformFactory( StateDescriptor<?, SV> stateDesc, StateSnapshotTransformFactory<SEV> snapshotTransformFactory) { if (stateDesc instanceof ListStateDescriptor) { return (StateSnapshotTransformFactory<SV>) new StateSnapshotTransformers.ListStateSnapshotTransformFactory<>(snapshotTransformFactory); } else if (stateDesc instanceof MapStateDescriptor) { return (StateSnapshotTransformFactory<SV>) new StateSnapshotTransformers.MapStateSnapshotTransformFactory<>(snapshotTransformFactory); } else { return (StateSnapshotTransformFactory<SV>) snapshotTransformFactory; } }
Example #26
Source File: TtlStateFactory.java From flink with Apache License 2.0 | 5 votes |
private StateSnapshotTransformFactory<?> getSnapshotTransformFactory() { if (!ttlConfig.getCleanupStrategies().inFullSnapshot()) { return StateSnapshotTransformFactory.noTransform(); } else { return new TtlStateSnapshotTransformer.Factory<>(timeProvider, ttl); } }
Example #27
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
public RegisteredKeyValueStateBackendMetaInfo( @Nonnull StateDescriptor.Type stateType, @Nonnull String name, @Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull TypeSerializer<S> stateSerializer) { this( stateType, name, StateSerializerProvider.fromNewRegisteredSerializer(namespaceSerializer), StateSerializerProvider.fromNewRegisteredSerializer(stateSerializer), StateSnapshotTransformFactory.noTransform()); }
Example #28
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
public RegisteredKeyValueStateBackendMetaInfo( @Nonnull StateDescriptor.Type stateType, @Nonnull String name, @Nonnull TypeSerializer<N> namespaceSerializer, @Nonnull TypeSerializer<S> stateSerializer, @Nonnull StateSnapshotTransformFactory<S> stateSnapshotTransformFactory) { this( stateType, name, StateSerializerProvider.fromNewRegisteredSerializer(namespaceSerializer), StateSerializerProvider.fromNewRegisteredSerializer(stateSerializer), stateSnapshotTransformFactory); }
Example #29
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public RegisteredKeyValueStateBackendMetaInfo(@Nonnull StateMetaInfoSnapshot snapshot) { this( StateDescriptor.Type.valueOf(snapshot.getOption(StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE)), snapshot.getName(), StateSerializerProvider.fromPreviousSerializerSnapshot( (TypeSerializerSnapshot<N>) Preconditions.checkNotNull( snapshot.getTypeSerializerSnapshot(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER))), StateSerializerProvider.fromPreviousSerializerSnapshot( (TypeSerializerSnapshot<S>) Preconditions.checkNotNull( snapshot.getTypeSerializerSnapshot(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER))), StateSnapshotTransformFactory.noTransform()); Preconditions.checkState(StateMetaInfoSnapshot.BackendStateType.KEY_VALUE == snapshot.getBackendStateType()); }
Example #30
Source File: RegisteredKeyValueStateBackendMetaInfo.java From flink with Apache License 2.0 | 5 votes |
private RegisteredKeyValueStateBackendMetaInfo( @Nonnull StateDescriptor.Type stateType, @Nonnull String name, @Nonnull StateSerializerProvider<N> namespaceSerializerProvider, @Nonnull StateSerializerProvider<S> stateSerializerProvider, @Nonnull StateSnapshotTransformFactory<S> stateSnapshotTransformFactory) { super(name); this.stateType = stateType; this.namespaceSerializerProvider = namespaceSerializerProvider; this.stateSerializerProvider = stateSerializerProvider; this.stateSnapshotTransformFactory = stateSnapshotTransformFactory; }