Skip to content

Commit

Permalink
data file size distribution metric; max file size 512mb
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedabu98 committed Oct 2, 2024
1 parent 47436f0 commit 9955868
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.io.IOException;
import org.apache.beam.sdk.metrics.Counter;
import org.apache.beam.sdk.metrics.Distribution;
import org.apache.beam.sdk.metrics.Metrics;
import org.apache.iceberg.DataFile;
import org.apache.iceberg.FileFormat;
Expand All @@ -38,6 +39,8 @@ class RecordWriter {
private static final Logger LOG = LoggerFactory.getLogger(RecordWriter.class);
private final Counter activeIcebergWriters =
Metrics.counter(RecordWriterManager.class, "activeIcebergWriters");
private final Distribution dataFileByteSize =
Metrics.distribution(RecordWriter.class, "dataFileByteSize");
private final DataWriter<Record> icebergDataWriter;
private final Table table;
private final String absoluteFilename;
Expand Down Expand Up @@ -117,13 +120,15 @@ public void close() throws IOException {
e);
}
activeIcebergWriters.dec();
DataFile dataFile = icebergDataWriter.toDataFile();
LOG.info(
"Closed {} writer for table '{}' ({} records, {} bytes), path: {}",
fileFormat,
table.name(),
icebergDataWriter.toDataFile().recordCount(),
icebergDataWriter.toDataFile().fileSizeInBytes(),
dataFile.recordCount(),
dataFile.fileSizeInBytes(),
absoluteFilename);
dataFileByteSize.update(dataFile.fileSizeInBytes());
}

public long bytesWritten() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class WriteGroupedRowsToFiles
extends PTransform<
PCollection<KV<ShardedKey<String>, Iterable<Row>>>, PCollection<FileWriteResult>> {

static final long DEFAULT_MAX_BYTES_PER_FILE = (1L << 40); // 1TB
private static final long DEFAULT_MAX_BYTES_PER_FILE = (1L << 29); // 512mb

private final DynamicDestinations dynamicDestinations;
private final IcebergCatalogConfig catalogConfig;
Expand Down

0 comments on commit 9955868

Please sign in to comment.