private static String toRecordLiteral(StringBuilder sb, DataMap dataMap, RecordDataSchema recordSchema) { Iterator<RecordDataSchema.Field> iter = recordSchema.getFields().iterator(); sb.append(escapeKeyword(recordSchema.getName())); sb.append("("); while (iter.hasNext()) { RecordDataSchema.Field field = iter.next(); sb.append(escapeKeyword(field.getName())); sb.append(": "); sb.append(toLiteral(field.getType(), dataMap.get(field.getName()))); if (iter.hasNext()) { sb.append(", "); } } sb.append(")"); return sb.toString(); }
for (RecordDataSchema.Field field : recordDataSchema.getFields())
fields.addAll(dereferencedIncludedRecordSchema.getFields()); includes.add(includedNamedSchema); if (isDeclaredInline(includeRef))
private static List<Map.Entry<String,Object>> orderMapEntries(RecordDataSchema schema, DataMap map) List<RecordDataSchema.Field> fields = schema.getFields();
@Override public void callback(List<String> path, DataSchema schema) { if (schema.getType() != DataSchema.Type.RECORD) { return; } RecordDataSchema recordSchema = (RecordDataSchema) schema; for (RecordDataSchema.Field field : recordSchema.getFields()) { Object defaultData = field.getDefault(); if (defaultData != null) { path.add(DataSchemaConstants.DEFAULT_KEY); Object newDefault = translateField(pathList(path), defaultData, field); path.remove(path.size() - 1); field.setDefault(newDefault); } } }
include.add(includedNamed); RecordDataSchema includedRecord = (RecordDataSchema) includedSchema.getDereferencedDataSchema(); fields.addAll(includedRecord.getFields());
for (RecordDataSchema.Field field : recordSchema.getFields())
for (RecordDataSchema.Field field : recordSchema.getFields())
/** * Encode a the fields of a {@link RecordDataSchema}. * * This method does not output a key. The key should be emitted before calling this method. * If {@link #isEncodeInclude()} returns true, then only fields that are defined in the record being * encoded will be encoded, else all fields including those from included records will be encoded. * * @param recordDataSchema the {@link RecordDataSchema} being encoded. * @throws IOException if there is an error while encoding. */ protected void encodeFields(RecordDataSchema recordDataSchema) throws IOException { Collection<RecordDataSchema.Field> fields = recordDataSchema.getFields(); _builder.writeStartArray(); boolean encodeInclude = isEncodeInclude(); for (RecordDataSchema.Field field : fields) { if (encodeInclude == false || recordDataSchema == field.getRecord()) { encodeField(field); } } _builder.writeEndArray(); }
for (RecordDataSchema.Field field : recordSchema.getFields())
if (dereferencedIncludedSchema instanceof RecordDataSchema) { RecordDataSchema includedRecordSchema = (RecordDataSchema) dereferencedIncludedSchema; results.addAll(includedRecordSchema.getFields());
@Override public void callback(List<String> path, DataSchema schema) { if (schema.getType() != DataSchema.Type.RECORD) { return; } // If schema has avro override, do not translate the record's aliased union fields. // These are handled in AvroOverrideFactory#createFromDataSchema() while encoding the Avro schema. if (schema.getProperties().get("avro") != null) { return; } RecordDataSchema recordSchema = (RecordDataSchema) schema; for (RecordDataSchema.Field field : recordSchema.getFields()) { DataSchema fieldSchema = field.getType().getDereferencedDataSchema(); // The conversion from Pegasus union type to an Avro record is performed when the union appears as either the // field's direct type or when the field's type is an array or a map whose (nested) elements is of union type. // This conversion ignores the default value when specified on an array or map typed field. Since the elements in // the default value collection can have conflicting union members, it will be hard to figure out the optionality // property of the fields in the generated Avro record. DataMap modifiedDefaultValue = modifyFieldDefaultValue(field, path); DataSchema modifiedSchema = modifyFieldSchema(recordSchema, field, fieldSchema, modifiedDefaultValue); if (modifiedSchema != null) { overrideUnionFieldSchemaAndDefault(field, modifiedSchema, modifiedDefaultValue); } } }
case RECORD: RecordDataSchema recordDataSchema = (RecordDataSchema) schema; for (RecordDataSchema.Field field : recordDataSchema.getFields())
for(RecordDataSchema.Field field : recordDataSchema.getFields())
for (RecordDataSchema.Field field : recordSchema.getFields())
for (RecordDataSchema.Field field : schema.getFields())
if (requiredMode != RequiredMode.IGNORE) for (RecordDataSchema.Field field : schema.getFields())
if (schema instanceof RecordDataSchema) for (RecordDataSchema.Field field: ((RecordDataSchema) schema).getFields())