當前位置: 首頁>>代碼示例>>Java>>正文


Java Schema.create方法代碼示例

本文整理匯總了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));
}
 
開發者ID:HotelsDotCom,項目名稱:avro-compatibility,代碼行數:29,代碼來源:TestSchemaCompatibility.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:4,代碼來源:TestParquetExport.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-maxcompute-data-collectors,代碼行數:4,代碼來源:TestAvroExport.java


注:本文中的org.apache.avro.Schema.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。