本文整理汇总了Java中org.apache.avro.Schema.create方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.create方法的具体用法?Java Schema.create怎么用?Java Schema.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.avro.Schema
的用法示例。
在下文中一共展示了Schema.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testValidatePrimitiveWriterSchema
import org.apache.avro.Schema; //导入方法依赖的package包/类
@Test
public void testValidatePrimitiveWriterSchema() throws Exception {
final Schema validReader = Schema.create(Schema.Type.STRING);
final SchemaCompatibility.SchemaPairCompatibility validResult =
new SchemaCompatibility.SchemaPairCompatibility(
SchemaCompatibility.SchemaCompatibilityResult.compatible(),
validReader,
STRING_SCHEMA,
SchemaCompatibility.READER_WRITER_COMPATIBLE_MESSAGE);
final SchemaCompatibility.SchemaPairCompatibility invalidResult =
new SchemaCompatibility.SchemaPairCompatibility(
SchemaCompatibility.SchemaCompatibilityResult.incompatible(SchemaIncompatibilityType.TYPE_MISMATCH, INT_SCHEMA, STRING_SCHEMA,
"reader type: INT not compatible with writer type: STRING", Arrays.asList("")),
INT_SCHEMA,
STRING_SCHEMA,
String.format(
"Data encoded using writer schema:%n%s%n"
+ "will or may fail to decode using reader schema:%n%s%n",
STRING_SCHEMA.toString(true),
INT_SCHEMA.toString(true)));
assertEquals(
validResult,
checkReaderWriterCompatibility(validReader, STRING_SCHEMA));
assertEquals(
invalidResult,
checkReaderWriterCompatibility(INT_SCHEMA, STRING_SCHEMA));
}
示例2: buildField
import org.apache.avro.Schema; //导入方法依赖的package包/类
private Field buildField(String name, Schema.Type type) {
return new Field(name, Schema.create(type), null, null);
}
示例3: buildAvroField
import org.apache.avro.Schema; //导入方法依赖的package包/类
private Field buildAvroField(String name, Schema.Type type) {
return new Field(name, Schema.create(type), null, null);
}