Java Code Examples for org.apache.flink.util.LinkedOptionalMap#KeyValue

The following examples show how to use org.apache.flink.util.LinkedOptionalMap#KeyValue . 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: PojoSerializerSnapshot.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Finds which Pojo fields exists both in the new {@link PojoSerializer} as well as in the previous one
 * (represented by this snapshot), and returns an {@link IntermediateCompatibilityResult}
 * of the serializers of those preexisting fields.
 */
private static <T> IntermediateCompatibilityResult<T> getCompatibilityOfPreExistingFields(
		PojoSerializer<T> newPojoSerializer,
		LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots) {

	// the present entries dictates the preexisting fields, because removed fields would be
	// represented as absent keys in the optional map.
	final Set<LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>>> presentFieldSnapshots =
		fieldSerializerSnapshots.getPresentEntries();

	final ArrayList<TypeSerializerSnapshot<?>> associatedFieldSerializerSnapshots = new ArrayList<>(presentFieldSnapshots.size());
	final ArrayList<TypeSerializer<?>> associatedNewFieldSerializers = new ArrayList<>(presentFieldSnapshots.size());

	final Map<Field, TypeSerializer<?>> newFieldSerializersIndex = buildNewFieldSerializersIndex(newPojoSerializer);
	for (LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>> presentFieldEntry : presentFieldSnapshots) {
		TypeSerializer<?> associatedNewFieldSerializer = newFieldSerializersIndex.get(presentFieldEntry.getKey());
		checkState(
			associatedNewFieldSerializer != null,
			"a present field should have its associated new field serializer available.");

		associatedFieldSerializerSnapshots.add(presentFieldEntry.getValue());
		associatedNewFieldSerializers.add(associatedNewFieldSerializer);
	}

	return CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult(
		associatedNewFieldSerializers.toArray(new TypeSerializer<?>[associatedNewFieldSerializers.size()]),
		associatedFieldSerializerSnapshots.toArray(new TypeSerializerSnapshot<?>[associatedFieldSerializerSnapshots.size()]));
}
 
Example 2
Source File: PojoSerializerSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Finds which Pojo fields exists both in the new {@link PojoSerializer} as well as in the previous one
 * (represented by this snapshot), and returns an {@link IntermediateCompatibilityResult}
 * of the serializers of those preexisting fields.
 */
private static <T> IntermediateCompatibilityResult<T> getCompatibilityOfPreExistingFields(
		PojoSerializer<T> newPojoSerializer,
		LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots) {

	// the present entries dictates the preexisting fields, because removed fields would be
	// represented as absent keys in the optional map.
	final Set<LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>>> presentFieldSnapshots =
		fieldSerializerSnapshots.getPresentEntries();

	final ArrayList<TypeSerializerSnapshot<?>> associatedFieldSerializerSnapshots = new ArrayList<>(presentFieldSnapshots.size());
	final ArrayList<TypeSerializer<?>> associatedNewFieldSerializers = new ArrayList<>(presentFieldSnapshots.size());

	final Map<Field, TypeSerializer<?>> newFieldSerializersIndex = buildNewFieldSerializersIndex(newPojoSerializer);
	for (LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>> presentFieldEntry : presentFieldSnapshots) {
		TypeSerializer<?> associatedNewFieldSerializer = newFieldSerializersIndex.get(presentFieldEntry.getKey());
		checkState(
			associatedNewFieldSerializer != null,
			"a present field should have its associated new field serializer available.");

		associatedFieldSerializerSnapshots.add(presentFieldEntry.getValue());
		associatedNewFieldSerializers.add(associatedNewFieldSerializer);
	}

	return CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult(
		associatedNewFieldSerializers.toArray(new TypeSerializer<?>[associatedNewFieldSerializers.size()]),
		associatedFieldSerializerSnapshots.toArray(new TypeSerializerSnapshot<?>[associatedFieldSerializerSnapshots.size()]));
}
 
Example 3
Source File: PojoSerializerSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Finds which Pojo fields exists both in the new {@link PojoSerializer} as well as in the previous one
 * (represented by this snapshot), and returns an {@link IntermediateCompatibilityResult}
 * of the serializers of those preexisting fields.
 */
private static <T> IntermediateCompatibilityResult<T> getCompatibilityOfPreExistingFields(
		PojoSerializer<T> newPojoSerializer,
		LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots) {

	// the present entries dictates the preexisting fields, because removed fields would be
	// represented as absent keys in the optional map.
	final Set<LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>>> presentFieldSnapshots =
		fieldSerializerSnapshots.getPresentEntries();

	final ArrayList<TypeSerializerSnapshot<?>> associatedFieldSerializerSnapshots = new ArrayList<>(presentFieldSnapshots.size());
	final ArrayList<TypeSerializer<?>> associatedNewFieldSerializers = new ArrayList<>(presentFieldSnapshots.size());

	final Map<Field, TypeSerializer<?>> newFieldSerializersIndex = buildNewFieldSerializersIndex(newPojoSerializer);
	for (LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>> presentFieldEntry : presentFieldSnapshots) {
		TypeSerializer<?> associatedNewFieldSerializer = newFieldSerializersIndex.get(presentFieldEntry.getKey());
		checkState(
			associatedNewFieldSerializer != null,
			"a present field should have its associated new field serializer available.");

		associatedFieldSerializerSnapshots.add(presentFieldEntry.getValue());
		associatedNewFieldSerializers.add(associatedNewFieldSerializer);
	}

	return CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult(
		associatedNewFieldSerializers.toArray(new TypeSerializer<?>[associatedNewFieldSerializers.size()]),
		associatedFieldSerializerSnapshots.toArray(new TypeSerializerSnapshot<?>[associatedFieldSerializerSnapshots.size()]));
}