/** * Encode a field's optional flag. * * @param field providing the optional flag to encode. * @throws IOException if there is an error while encoding. */ protected void encodeFieldOptional(RecordDataSchema.Field field) throws IOException { boolean optional = field.getOptional(); if (optional) { _builder.writeBooleanField(OPTIONAL_KEY, optional); } }