@Override protected void encodeField(RecordDataSchema.Field field) throws IOException { super.encodeField(field); // Reset the field's type and default if there is an override FieldOverride schemaOverride = _fieldOverridesProvider.getSchemaOverride(field); if (schemaOverride != null) { field.setType(schemaOverride.getSchema()); field.setDefault(schemaOverride.getValue()); } }
/** * 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(); }