use of org.apache.iceberg.io.ClusteredDataWriter in project iceberg by apache.
the class WritersBenchmark method writePartitionedClusteredDataWriter.
@Benchmark
@Threads(1)
public void writePartitionedClusteredDataWriter(Blackhole blackhole) throws IOException {
FileIO io = table().io();
OutputFileFactory fileFactory = newFileFactory();
SparkFileWriterFactory writerFactory = SparkFileWriterFactory.builderFor(table()).dataFileFormat(fileFormat()).dataSchema(table().schema()).build();
ClusteredDataWriter<InternalRow> writer = new ClusteredDataWriter<>(writerFactory, fileFactory, io, fileFormat(), TARGET_FILE_SIZE_IN_BYTES);
PartitionKey partitionKey = new PartitionKey(partitionedSpec, table().schema());
StructType dataSparkType = SparkSchemaUtil.convert(table().schema());
InternalRowWrapper internalRowWrapper = new InternalRowWrapper(dataSparkType);
try (ClusteredDataWriter<InternalRow> closeableWriter = writer) {
for (InternalRow row : rows) {
partitionKey.partition(internalRowWrapper.wrap(row));
closeableWriter.write(row, partitionedSpec, partitionKey);
}
}
blackhole.consume(writer);
}
use of org.apache.iceberg.io.ClusteredDataWriter in project iceberg by apache.
the class WritersBenchmark method writeUnpartitionedClusteredDataWriter.
@Benchmark
@Threads(1)
public void writeUnpartitionedClusteredDataWriter(Blackhole blackhole) throws IOException {
FileIO io = table().io();
OutputFileFactory fileFactory = newFileFactory();
SparkFileWriterFactory writerFactory = SparkFileWriterFactory.builderFor(table()).dataFileFormat(fileFormat()).dataSchema(table().schema()).build();
ClusteredDataWriter<InternalRow> writer = new ClusteredDataWriter<>(writerFactory, fileFactory, io, fileFormat(), TARGET_FILE_SIZE_IN_BYTES);
try (ClusteredDataWriter<InternalRow> closeableWriter = writer) {
for (InternalRow row : rows) {
closeableWriter.write(row, unpartitionedSpec, null);
}
}
blackhole.consume(writer);
}
Aggregations