Optimize parquet_files_to_data_files by reusing schema index
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- performance
Research direction
Start in crates/iceberg/src/writer/file_writer/parquet_writer.rs at parquet_files_to_data_files and parquet_to_data_file_builder, then inspect IndexByParquetPathName creation and its use. The work is done when the schema index is built once before the file loop, passed by reference to the builder, and reused for every file without changing the resulting DataFile values.
Written by the indexing model from the issue text.
Description
In the current implementation of parquet_files_to_data_files in parquet_writer.rs, we iterate over a list of files to convert them into Iceberg
DataFile structs.
However, for every single file in the loop, we invoke
parquet_to_data_file_builder
, which internally rebuilds the schema index from scratch:
// crates/iceberg/src/writer/file_writer/parquet_writer.rs
pub(crate) fn parquet_to_data_file_builder(...) -> Result<DataFileBuilder> {
// This runs for every file!
let index_by_parquet_path = {
let mut visitor = IndexByParquetPathName::new();
visit_schema(&schema, &mut visitor)?;
visitor
};
// ...
}
Problem: When importing a large number of files (e.g., thousands of files in a bulk import), we are traversing the entire schema and allocating a new name_to_id HashMap thousands of times, even though the schema is constant for the entire operation.
Proposed Solution:
- Extract the IndexByParquetPathName creation logic out of parquet_to_data_file_builder
https://github.com/apache/iceberg-rust/blob/b05a675db44645becc60422b596f16cca8816a89/crates/iceberg/src/writer/file_writer/parquet_writer.rs#L357-L361 - Compute this index once at the beginning of parquet_files_to_data_files (outside the loop).
https://github.com/apache/iceberg-rust/blob/b05a675db44645becc60422b596f16cca8816a89/crates/iceberg/src/writer/file_writer/parquet_writer.rs#L320-L344 - Update parquet_to_data_file_builder to accept the index as a reference argument.
- Reuse the same index for every file iteration.
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 574
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 84
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iceberg-rust
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/iceberg-rust#3234 · 1 reaction ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/iceberg-rust#3229 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/iceberg-rust#3222 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/iceberg-rust#2929 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/iceberg-rust#2923 · 1 comment · 2 reactions ·
All issues in apache/iceberg-rust
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100