org.apache.avro.SchemaCompatibility.SchemaPairCompatibility Java Examples

The following examples show how to use org.apache.avro.SchemaCompatibility.SchemaPairCompatibility. 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: AvroSerializerSnapshot.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static <T> TypeSerializerSchemaCompatibility<T>
avroCompatibilityToFlinkCompatibility(SchemaPairCompatibility compatibility) {

	switch (compatibility.getType()) {
		case COMPATIBLE: {
			// The new serializer would be able to read data persisted with *this* serializer, therefore no migration
			// is required.
			return TypeSerializerSchemaCompatibility.compatibleAfterMigration();
		}
		case INCOMPATIBLE: {
			return TypeSerializerSchemaCompatibility.incompatible();
		}
		case RECURSION_IN_PROGRESS:
		default:
			return TypeSerializerSchemaCompatibility.incompatible();
	}
}
 
Example #2
Source File: AvroSerializerSnapshot.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <T> TypeSerializerSchemaCompatibility<T>
avroCompatibilityToFlinkCompatibility(SchemaPairCompatibility compatibility) {

	switch (compatibility.getType()) {
		case COMPATIBLE: {
			// The new serializer would be able to read data persisted with *this* serializer, therefore no migration
			// is required.
			return TypeSerializerSchemaCompatibility.compatibleAfterMigration();
		}
		case INCOMPATIBLE: {
			return TypeSerializerSchemaCompatibility.incompatible();
		}
		case RECURSION_IN_PROGRESS:
		default:
			return TypeSerializerSchemaCompatibility.incompatible();
	}
}
 
Example #3
Source File: AvroSerializerSnapshot.java    From flink with Apache License 2.0 6 votes vote down vote up
private static <T> TypeSerializerSchemaCompatibility<T>
avroCompatibilityToFlinkCompatibility(SchemaPairCompatibility compatibility) {

	switch (compatibility.getType()) {
		case COMPATIBLE: {
			// The new serializer would be able to read data persisted with *this* serializer, therefore no migration
			// is required.
			return TypeSerializerSchemaCompatibility.compatibleAfterMigration();
		}
		case INCOMPATIBLE: {
			return TypeSerializerSchemaCompatibility.incompatible();
		}
		case RECURSION_IN_PROGRESS:
		default:
			return TypeSerializerSchemaCompatibility.incompatible();
	}
}
 
Example #4
Source File: AvroSerializerSnapshot.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Resolves writer/reader schema compatibly.
 *
 * <p>Checks whenever a new version of a schema (reader) can read values serialized with the old schema (writer).
 * If the schemas are compatible according to {@code Avro} schema resolution rules
 * (@see <a href="https://avro.apache.org/docs/current/spec.html#Schema+Resolution">Schema Resolution</a>).
 */
@VisibleForTesting
static <T> TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(
	Schema writerSchema,
	Schema readerSchema) {

	if (Objects.equals(writerSchema, readerSchema)) {
		return TypeSerializerSchemaCompatibility.compatibleAsIs();
	}

	final SchemaPairCompatibility compatibility =
		SchemaCompatibility.checkReaderWriterCompatibility(readerSchema, writerSchema);

	return avroCompatibilityToFlinkCompatibility(compatibility);
}
 
Example #5
Source File: AvroSerializerSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Resolves writer/reader schema compatibly.
 *
 * <p>Checks whenever a new version of a schema (reader) can read values serialized with the old schema (writer).
 * If the schemas are compatible according to {@code Avro} schema resolution rules
 * (@see <a href="https://avro.apache.org/docs/current/spec.html#Schema+Resolution">Schema Resolution</a>).
 */
@VisibleForTesting
static <T> TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(
	Schema writerSchema,
	Schema readerSchema) {

	if (Objects.equals(writerSchema, readerSchema)) {
		return TypeSerializerSchemaCompatibility.compatibleAsIs();
	}

	final SchemaPairCompatibility compatibility =
		SchemaCompatibility.checkReaderWriterCompatibility(readerSchema, writerSchema);

	return avroCompatibilityToFlinkCompatibility(compatibility);
}
 
Example #6
Source File: AvroSerializerSnapshot.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Resolves writer/reader schema compatibly.
 *
 * <p>Checks whenever a new version of a schema (reader) can read values serialized with the old schema (writer).
 * If the schemas are compatible according to {@code Avro} schema resolution rules
 * (@see <a href="https://avro.apache.org/docs/current/spec.html#Schema+Resolution">Schema Resolution</a>).
 */
@VisibleForTesting
static <T> TypeSerializerSchemaCompatibility<T> resolveSchemaCompatibility(
	Schema writerSchema,
	Schema readerSchema) {

	if (Objects.equals(writerSchema, readerSchema)) {
		return TypeSerializerSchemaCompatibility.compatibleAsIs();
	}

	final SchemaPairCompatibility compatibility =
		SchemaCompatibility.checkReaderWriterCompatibility(readerSchema, writerSchema);

	return avroCompatibilityToFlinkCompatibility(compatibility);
}