当前位置: 首页>>代码示例>>Java>>正文


Java SchemaCompatibility类代码示例

本文整理汇总了Java中org.apache.avro.SchemaCompatibility的典型用法代码示例。如果您正苦于以下问题:Java SchemaCompatibility类的具体用法?Java SchemaCompatibility怎么用?Java SchemaCompatibility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SchemaCompatibility类属于org.apache.avro包,在下文中一共展示了SchemaCompatibility类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: verifyAvroBehaviour_SchemaCompatibility

import org.apache.avro.SchemaCompatibility; //导入依赖的package包/类
/**
 * It is valid when using a canBeReadStrategy for messages to arrive with fields not declared in the earlier
 * schema.
 */
@Test
public void verifyAvroBehaviour_SchemaCompatibility() throws SchemaValidationException {
  Schema newSchema = SchemaBuilder.record("a").fields().requiredString("x").requiredString("y").endRecord();
  Schema oldSchema = SchemaBuilder.record("a").fields().requiredString("x").endRecord();
  SchemaCompatibilityType compatibilityType = SchemaCompatibility
      .checkReaderWriterCompatibility(oldSchema, newSchema)
      .getType();
  assertThat(compatibilityType, is(SchemaCompatibilityType.COMPATIBLE));
}
 
开发者ID:HotelsDotCom,项目名称:jasvorno,代码行数:14,代码来源:UndeclaredFieldsTest.java

示例2: ensureCompatibility

import org.apache.avro.SchemaCompatibility; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public CompatibilityResult<T> ensureCompatibility(TypeSerializerConfigSnapshot configSnapshot) {
	if (configSnapshot instanceof AvroSchemaSerializerConfigSnapshot) {
		// proper schema snapshot, can do the sophisticated schema-based compatibility check
		final String schemaString = ((AvroSchemaSerializerConfigSnapshot) configSnapshot).getSchemaString();
		final Schema lastSchema = new Schema.Parser().parse(schemaString);

		checkAvroInitialized();
		final SchemaPairCompatibility compatibility =
				SchemaCompatibility.checkReaderWriterCompatibility(schema, lastSchema);

		return compatibility.getType() == SchemaCompatibilityType.COMPATIBLE ?
				CompatibilityResult.compatible() : CompatibilityResult.requiresMigration();
	}
	else if (configSnapshot instanceof AvroSerializerConfigSnapshot) {
		// old snapshot case, just compare the type
		// we don't need to restore any Kryo stuff, since Kryo was never used for persistence,
		// only for object-to-object copies.
		final AvroSerializerConfigSnapshot old = (AvroSerializerConfigSnapshot) configSnapshot;
		return type.equals(old.getTypeClass()) ?
				CompatibilityResult.compatible() : CompatibilityResult.requiresMigration();
	}
	else {
		return CompatibilityResult.requiresMigration();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:28,代码来源:AvroSerializer.java

示例3: schemaBackwardCompatibility

import org.apache.avro.SchemaCompatibility; //导入依赖的package包/类
public SchemaCompatiblityCheck schemaBackwardCompatibility(SchemaDTO schemaDto) {

    String schemaContent = schemaDto.getContents();

    SchemaCompatibility.SchemaPairCompatibility schemaCompatibility;
    Schema writer;

    TypedQuery<SchemaTopics> query = em.createNamedQuery(
        "SchemaTopics.findByName", SchemaTopics.class);
    query.setParameter("name", schemaDto.getName());

    try {
      Schema reader = new Schema.Parser().parse(schemaContent);

      for (SchemaTopics schemaTopic : query.getResultList()) {

        writer = new Schema.Parser().parse(schemaTopic.getContents());

        schemaCompatibility = SchemaCompatibility.
            checkReaderWriterCompatibility(reader, writer);

        switch (schemaCompatibility.getType()) {

          case COMPATIBLE:
            break;
          case INCOMPATIBLE:
            return SchemaCompatiblityCheck.INCOMPATIBLE;
          case RECURSION_IN_PROGRESS:
            break;
        }
      }
    } catch (SchemaParseException ex) {
      return SchemaCompatiblityCheck.INVALID;
    }
    return SchemaCompatiblityCheck.COMPATIBLE;
  }
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:37,代码来源:KafkaFacade.java

示例4: isKeySchemaValid

import org.apache.avro.SchemaCompatibility; //导入依赖的package包/类
/**
 * keySchema is valid if a record with newestSchema can be converted to a record with keySchema.
 */
private boolean isKeySchemaValid(Schema keySchema, Schema topicSchema) {
  return SchemaCompatibility.checkReaderWriterCompatibility(keySchema, topicSchema).getType()
      .equals(SchemaCompatibilityType.COMPATIBLE);
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:8,代码来源:MRCompactorAvroKeyDedupJobRunner.java

示例5: isKeySchemaValid

import org.apache.avro.SchemaCompatibility; //导入依赖的package包/类
/**
 * keySchema is valid if a record with newestSchema can be converted to a record with keySchema.
 */
public static boolean isKeySchemaValid(Schema keySchema, Schema topicSchema) {
  return SchemaCompatibility.checkReaderWriterCompatibility(keySchema, topicSchema).getType()
      .equals(SchemaCompatibilityType.COMPATIBLE);
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:8,代码来源:MRCompactorAvroKeyDedupJobRunner.java


注:本文中的org.apache.avro.SchemaCompatibility类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。