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


Java Schema.createMap方法代碼示例

本文整理匯總了Java中org.apache.avro.Schema.createMap方法的典型用法代碼示例。如果您正苦於以下問題:Java Schema.createMap方法的具體用法?Java Schema.createMap怎麽用?Java Schema.createMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.avro.Schema的用法示例。


在下文中一共展示了Schema.createMap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testValidateArrayWriterSchema

import org.apache.avro.Schema; //導入方法依賴的package包/類
@Test
public void testValidateArrayWriterSchema() throws Exception {
  final Schema validReader = Schema.createArray(STRING_SCHEMA);
  final Schema invalidReader = Schema.createMap(STRING_SCHEMA);
  final SchemaCompatibility.SchemaPairCompatibility validResult =
      new SchemaCompatibility.SchemaPairCompatibility(
          SchemaCompatibility.SchemaCompatibilityResult.compatible(),
          validReader,
          STRING_ARRAY_SCHEMA,
          SchemaCompatibility.READER_WRITER_COMPATIBLE_MESSAGE);
  final SchemaCompatibility.SchemaPairCompatibility invalidResult =
      new SchemaCompatibility.SchemaPairCompatibility(
          SchemaCompatibility.SchemaCompatibilityResult.incompatible(SchemaIncompatibilityType.TYPE_MISMATCH, invalidReader, STRING_ARRAY_SCHEMA, 
              "reader type: MAP not compatible with writer type: ARRAY", Arrays.asList("")),
          invalidReader,
          STRING_ARRAY_SCHEMA,
          String.format(
              "Data encoded using writer schema:%n%s%n"
              + "will or may fail to decode using reader schema:%n%s%n",
              STRING_ARRAY_SCHEMA.toString(true),
              invalidReader.toString(true)));

  assertEquals(
      validResult,
      checkReaderWriterCompatibility(validReader, STRING_ARRAY_SCHEMA));
  assertEquals(
      invalidResult,
      checkReaderWriterCompatibility(invalidReader, STRING_ARRAY_SCHEMA));
}
 
開發者ID:HotelsDotCom,項目名稱:avro-compatibility,代碼行數:30,代碼來源:TestSchemaCompatibility.java

示例2: getComplexTypeDesc

import org.apache.avro.Schema; //導入方法依賴的package包/類
private Schema getComplexTypeDesc(DataType type) {
  Schema resultTypeInfo = null;
  switch (type.getCategory()) {
    case Basic:
      resultTypeInfo = parquetAvroSchemaMap.get(type.toString());
      break;
    case Struct:
      // create record here
      StructType structObjectType = (StructType) type;

      List<DataType> dataTypes = Arrays.asList(structObjectType.getColumnTypes());
      Schema[] schemas = dataTypes.stream().map(dataType -> getComplexTypeDesc(dataType))
          .toArray(size -> new Schema[size]);

      resultTypeInfo = ParquetUtils.createAvroRecordSchema(columnName,
          structObjectType.getColumnNames(), schemas);
      break;
    case List:
      resultTypeInfo =
          Schema.createArray(getComplexTypeDesc(((ListType) type).getTypeOfElement()));
      break;
    case Union:
      final UnionType unionObjectType = (UnionType) type;
      final DataType[] columnTypes1 = unionObjectType.getColumnTypes();
      List<Schema> colTypes = new ArrayList<>();
      for (int i = 0; i < columnTypes1.length; i++) {
        colTypes.add(getComplexTypeDesc(columnTypes1[i]));
      }
      resultTypeInfo = Schema.createUnion(colTypes);
      break;
    case Map:
      MapType mapObjectType = (MapType) type;
      resultTypeInfo = Schema.createMap(getComplexTypeDesc(mapObjectType.getTypeOfValue()));
      break;
    default:
      break;

  }
  return resultTypeInfo;
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:41,代碼來源:ParquetColumnConverterDescriptor.java

示例3: AvroMapSchema

import org.apache.avro.Schema; //導入方法依賴的package包/類
public AvroMapSchema( final MapContainerField schema ) throws IOException{
  this.schema = schema;
  Schema childSchema = AvroSchemaFactory.getAvroSchema( schema.getField() );
  avroSchema = Schema.createMap( childSchema );
}
 
開發者ID:yahoojapan,項目名稱:dataplatform-schema-lib,代碼行數:6,代碼來源:AvroMapSchema.java


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