@VisibleForTesting
@SuppressWarnings("unchecked")
<E> FileAppender<E> newAppender(Path temp) {
Format format = descriptor.getFormat();
if (Formats.PARQUET.equals(format)) {
if (DescriptorUtil.isDisabled(
FileSystemProperties.NON_DURABLE_PARQUET_PROP, descriptor)) {
return (FileAppender<E>) new DurableParquetAppender(
fs, temp, schema, conf, descriptor.getCompressionType());
} else {
return (FileAppender<E>) new ParquetAppender(
fs, temp, schema, conf,
descriptor.getCompressionType());
}
} else if (Formats.AVRO.equals(format)) {
return new AvroAppender<E>(fs, temp, schema,
descriptor.getCompressionType());
} else if (Formats.CSV.equals(format) &&
DescriptorUtil.isEnabled(FileSystemProperties.ALLOW_CSV_PROP, descriptor)) {
return new CSVAppender<E>(fs, temp, descriptor);
} else {
this.state = ReaderWriterState.ERROR;
throw new UnknownFormatException("Unknown format " + descriptor);
}
}