/** * 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(); }
case RECORD: RecordDataSchema recordDataSchema = (RecordDataSchema) schema; boolean hasIncludes = isEncodeInclude() && !recordDataSchema.getInclude().isEmpty(); boolean fieldsBeforeIncludes = recordDataSchema.isFieldsBeforeIncludes(); if (hasIncludes && !fieldsBeforeIncludes)