Пример #1
0
 Schema computeAvroSchema() {
   List<Schema.Field> fields = new ArrayList<Schema.Field>();
   for (InferredType it : structTypes) {
     Schema itS = it.getAvroSchema();
     if (itS == null) {
       continue;
     }
     fields.add(
         new Schema.Field(
             it.getName(), it.getAvroSchema(), it.getDocString(), it.getDefaultValue()));
   }
   Schema s = Schema.createRecord(name, "RECORD", "", false);
   s.setFields(fields);
   return s;
 }
Пример #2
0
 Schema computeAvroSchema() {
   HashSet<String> observedSchemas = new HashSet<String>();
   List<Schema> fields = new ArrayList<Schema>();
   for (InferredType it : unionTypes) {
     Schema itS = it.getAvroSchema();
     if (itS == null) {
       continue;
     }
     String schemaDesc = itS.toString();
     if (!observedSchemas.contains(schemaDesc)) {
       observedSchemas.add(schemaDesc);
       fields.add(it.getAvroSchema());
     }
   }
   return Schema.createUnion(fields);
 }
Пример #3
0
 Schema computeAvroSchema() {
   return Schema.createArray(bodyType.getAvroSchema());
 }