Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #11384.
Rationale for this change
Approximate parquet-java's first-page dictionary choice from Arrow samples before writing, without changing writer defaults.
What changes are included in this PR?
Adds
choose_dictionary_encodingandDictionaryEncodingOptions. Dictionaries are disabled when sampled dictionary and index bytes are not smaller than raw bytes, or the dictionary size limit is exceeded. Nonempty samples also disable Parquet v1 fixed-length byte-array dictionaries.Sampling stops at the first-page or row-group row limit. The first size check is configurable. Row-group byte limits and custom Parquet schemas are not supported. Page boundaries can differ from parquet-java because size is checked every row and level bytes are excluded. Parquet-java may merge different NaN payloads; this helper distinguishes them. Small samples can reject useful dictionaries.
Uses the existing
ahash::RandomState. Fixed-width keys are stored in hash-table buckets, avoiding per-key heap allocations. Small-batch total cost can still exceed writing without sampling.Adapted from Comet's DictionaryChooser.
Are these changes tested?
25 unit tests, including parquet-java decisions recorded through Iceberg (ported from Comet) and file readback, plus a doc example.
Local measurements
Commit
05a779244; Ratio = (sampling + write) / write without sampling.(Apple M4 Max, macOS, Rust 1.99.1, release opt-level 3, 16 codegen units, no LTO; in-memory files; median of 20 runs per input; 20,000-row sample in each case)
List<Int32>(20k)Int64(20k)Int64with nulls (20k)For small batches, sampling plus writing still costs more than writing without sampling. These are microbenchmarks, not end-to-end results.
Are there any significant user-facing changes?
New opt-in API. Existing writer behavior is unchanged.
AI usage disclosure
AI tools adapted the reference implementation and generated the helper, tests, and documentation.