Repository navigation
Conversation
Adds `string_dictionary_shared_by_batches`: 256 batches of 4,096 rows, slices of one dictionary column whose dictionary has 32,768 values, more than any one batch has rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The byte array dictionary encoder starts a dictionary cache only when one write references at least as many rows as the dictionary has values. A dictionary larger than each write, but shared by the writes that follow, never got one, and every row was hashed into the interner. Rows encoded without the cache now count toward that threshold while consecutive writes carry the same dictionary allocation. A single write decides as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
13 tasks
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?
Rationale for this change
The byte array dictionary encoder caches each arrow dictionary value's interned index, so a value is hashed once rather than once per row (#11982). It starts that cache only when one write references at least as many rows as the dictionary has values (#12122).
A dictionary with more values than any one write has rows, shared by the writes that follow, never gets a cache: every row is hashed into the interner. That is the shape a reader produces when it keeps one dictionary across batches, for example slices of one dictionary column, or the batches of an external sort whose runs share a dictionary.
What changes are included in this PR?
write_batch_sizeor the page limit counts its rows once. A different dictionary in between starts the count again. A single write decides exactly as before.u64per dictionary value per column chunk, and still starts only once at least that many rows have referenced the dictionary.string_dictionary_shared_by_batches, as the first commit: 256 batches of 4,096 rows, slices of oneDictionary<Int32, Utf8>column whose dictionary has 32,768 values.Are these changes tested?
Yes.
use_dictionary_cache_dictionary_shared_by_writescovers a dictionary shared by consecutive writes, a write split into several calls, and another dictionary in between. The two existing cache tests are updated for the new signature and keep their cases.arrow_writerbenchmarks on an Apple M-series laptop: the cases #11982 reported, plus the newstring_dictionary_shared_by_batches. "main" is this PR's first commit (main plus the benchmark); each side ran on an otherwise idle machine.string/defaultstring/parquet_2string_dictionary/defaultstring_dictionary/parquet_2string_dictionary_low_cardinality_100/defaultstring_dictionary_low_cardinality_100/parquet_2string_non_null/defaultstring_non_null/parquet_2string_ree_of_dict/defaultstring_ree_of_dict/parquet_2string_dictionary_shared_by_batches/defaultOnly the last case writes one dictionary across several writes. The other cases take the same path as before, so their differences of up to 3% are run-to-run variance (the
string_non_nullcases have no dictionary column at all).Are there any significant user-facing changes?
No. The encoded output is unchanged: the cached path interns each value at the first row that references it, as the uncached path does.
AI usage disclosure
Claude (Anthropic) helped find the cause, write the change, its tests and the benchmark, and draft this description. I reviewed and ran all of it.
🤖 Generated with Claude Code