/// <summary> /// Appends data to the end of the Avro file currently being written to. /// </summary> /// <param name="fields">An array of strings containing the data to be appended.</param> /// <exception cref="InvalidOperationException">Thrown when some fields have null values that are not allowed by the schema.</exception> /// <exception cref="FormatException">Thrown when a field value cannot be converted to the data type for that field in the schema.</exception> /// <exception cref="NotSupportedException">Thrown when a particular data type is not supported for a field in the schema.</exception> public void Append(string[] fields) { GenericRecord record = GetGenericRecord(fields); IEnumerable <Field> invalidNullFields = GetInvalidNullFields(record); if (invalidNullFields.Any()) { throw new InvalidOperationException( $"There are fields with null, values but the schema does not allow for null: {string.Join(", ", invalidNullFields)}."); } _dataFileWriter.Append(record); }
/// <summary> /// Appends data to the end of the Avro file currently being written to. /// </summary> /// <param name="record">A record of a type that implements ISpecificRecord.</param> /// <param name="fields">An array of strings containing the data to be appended.</param> /// <exception cref="ArgumentNullException"><paramref name="record">record</paramref> is null.</exception> /// <exception cref="InvalidOperationException">Thrown when some fields have null values that are not allowed by the schema.</exception> /// <exception cref="FormatException">Thrown when a field value cannot be converted to the data type for that field in the schema.</exception> /// <exception cref="NotSupportedException">Thrown when a particular data type is not supported for a field in the schema.</exception> public void Append(T record, string[] fields) { if (record == null) { throw new ArgumentNullException(nameof(record)); } PopulateSpecificRecord(record, fields); IEnumerable <Field> invalidNullFields = GetInvalidNullFields(record); if (invalidNullFields.Any()) { throw new InvalidOperationException( $"There are fields with null, values but the schema does not allow for null: {string.Join(", ", invalidNullFields)}."); } _dataFileWriter.Append(record); }