Java Code Examples for org.apache.flink.api.common.state.StateDescriptor#Type

The following examples show how to use org.apache.flink.api.common.state.StateDescriptor#Type . 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: LegacyStateMetaInfoReaders.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();
	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		serializersAndConfigs.get(0).f1);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		serializersAndConfigs.get(1).f1);

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 2
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();
	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		serializersAndConfigs.get(0).f1);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		serializersAndConfigs.get(1).f1);

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 3
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in, @Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();
	List<Tuple2<TypeSerializer<?>, TypeSerializerSnapshot<?>>> serializersAndConfigs =
		TypeSerializerSerializationUtil.readSerializersAndConfigsWithResilience(in, userCodeClassLoader);

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		serializersAndConfigs.get(0).f1);
	serializerConfigSnapshotMap.put(StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		serializersAndConfigs.get(1).f1);

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 4
Source File: LegacyStateMetaInfoReaders.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in,
	@Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(
		StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		new BackwardsCompatibleSerializerSnapshot<>(
			TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)));
	serializerConfigSnapshotMap.put(
		StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		new BackwardsCompatibleSerializerSnapshot<>(
			TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)));

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 5
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
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 6
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
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 7
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
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 8
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in,
	@Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(
		StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		new BackwardsCompatibleSerializerSnapshot<>(
			TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)));
	serializerConfigSnapshotMap.put(
		StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		new BackwardsCompatibleSerializerSnapshot<>(
			TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)));

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 9
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
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 10
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
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 11
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 5 votes vote down vote up
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 12
Source File: LegacyStateMetaInfoReaders.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public StateMetaInfoSnapshot readStateMetaInfoSnapshot(
	@Nonnull DataInputView in,
	@Nonnull ClassLoader userCodeClassLoader) throws IOException {

	final StateDescriptor.Type stateDescType = StateDescriptor.Type.values()[in.readInt()];
	final String stateName = in.readUTF();

	Map<String, String> optionsMap = Collections.singletonMap(
		StateMetaInfoSnapshot.CommonOptionsKeys.KEYED_STATE_TYPE.toString(),
		stateDescType.toString());

	Map<String, TypeSerializerSnapshot<?>> serializerConfigSnapshotMap = new HashMap<>(2);
	serializerConfigSnapshotMap.put(
		StateMetaInfoSnapshot.CommonSerializerKeys.NAMESPACE_SERIALIZER.toString(),
		new BackwardsCompatibleSerializerSnapshot<>(
			TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)));
	serializerConfigSnapshotMap.put(
		StateMetaInfoSnapshot.CommonSerializerKeys.VALUE_SERIALIZER.toString(),
		new BackwardsCompatibleSerializerSnapshot<>(
			TypeSerializerSerializationUtil.tryReadSerializer(in, userCodeClassLoader, true)));

	return new StateMetaInfoSnapshot(
		stateName,
		StateMetaInfoSnapshot.BackendStateType.KEY_VALUE,
		optionsMap,
		serializerConfigSnapshotMap);
}
 
Example 13
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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 14
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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 15
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
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 16
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
public StateDescriptor.Type getStateType() {
	return stateType;
}
 
Example 17
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Nonnull
public StateDescriptor.Type getStateType() {
	return stateType;
}
 
Example 18
Source File: RegisteredKeyValueStateBackendMetaInfo.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
public StateDescriptor.Type getStateType() {
	return stateType;
}