本文整理匯總了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);
}