• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SchemaCompatibility类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConstraintKind类代码示例发布时间:2022-05-22
下一篇:
Java NotImplemented类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap