use of org.apache.iceberg.io.UnpartitionedWriter in project iceberg by apache.
the class WritersBenchmark method writeUnpartitionedLegacyDataWriter.
@Benchmark
@Threads(1)
public void writeUnpartitionedLegacyDataWriter(Blackhole blackhole) throws IOException {
FileIO io = table().io();
OutputFileFactory fileFactory = newFileFactory();
Schema writeSchema = table().schema();
StructType sparkWriteType = SparkSchemaUtil.convert(writeSchema);
SparkAppenderFactory appenders = SparkAppenderFactory.builderFor(table(), writeSchema, sparkWriteType).spec(unpartitionedSpec).build();
TaskWriter<InternalRow> writer = new UnpartitionedWriter<>(unpartitionedSpec, fileFormat(), appenders, fileFactory, io, TARGET_FILE_SIZE_IN_BYTES);
try (TaskWriter<InternalRow> closableWriter = writer) {
for (InternalRow row : rows) {
closableWriter.write(row);
}
}
blackhole.consume(writer.complete());
}
Aggregations