Search in sources :

Example 1 with UnpartitionedWriter

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());
}
Also used : OutputFileFactory(org.apache.iceberg.io.OutputFileFactory) StructType(org.apache.spark.sql.types.StructType) Schema(org.apache.iceberg.Schema) UnpartitionedWriter(org.apache.iceberg.io.UnpartitionedWriter) InternalRow(org.apache.spark.sql.catalyst.InternalRow) FileIO(org.apache.iceberg.io.FileIO) Threads(org.openjdk.jmh.annotations.Threads) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

Schema (org.apache.iceberg.Schema)1 FileIO (org.apache.iceberg.io.FileIO)1 OutputFileFactory (org.apache.iceberg.io.OutputFileFactory)1 UnpartitionedWriter (org.apache.iceberg.io.UnpartitionedWriter)1 InternalRow (org.apache.spark.sql.catalyst.InternalRow)1 StructType (org.apache.spark.sql.types.StructType)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 Threads (org.openjdk.jmh.annotations.Threads)1