Repository navigation
Conversation
Jefffrey
requested changes
Nov 25, 2026
Contributor
There was a problem hiding this comment.
we should just shadow this like
let value: &T::Native = value.as_ref();
Comment on lines
+278
to
+279
| // Store the bytes that were hashed above, not a second s_ref() | ||
| // of alue, which is not required to be idempotent. |
Contributor
There was a problem hiding this comment.
Suggested change
| // Store the bytes that were hashed above, not a second �s_ref() | |
| // of �alue, which is not required to be idempotent. |
not necessary
|
|
||
| /// A legal `AsRef<str>` whose result changes between calls, so the value | ||
| /// that is hashed can differ from the value that is stored. | ||
| struct AlternatingValue(Cell<u32>); |
Contributor
There was a problem hiding this comment.
this is overkill and unnecessary, please remove these tests
compiler-segfault
force-pushed
the
fix/dict-builder-hash-store-same-bytes
branch
from
November 26, 2026 08:12
b60e3ba to
9a55ab6
Compare
`GenericByteDictionaryBuilder::get_or_insert_key` hashed `value.as_ref()` and then called `value.as_ref()` again through `storage.append_value(value)`. `AsRef` is not required to be idempotent, so the stored bytes could differ from the hashed bytes: the dictionary then holds a value filed under the wrong hash, and a later append of the value that was actually hashed adds a duplicate entry. Store the same `&T::Native` that was hashed, the way apache#12397 did it for the fixed-size binary dictionary builder. Fixes apache#12424.
compiler-segfault
force-pushed
the
fix/dict-builder-hash-store-same-bytes
branch
from
November 26, 2026 08:18
9a55ab6 to
c4b2754
Compare
Contributor
Author
|
Applied the shadowing as suggested: the argument is now rebound to
|
Jefffrey
approved these changes
Nov 26, 2026
AsRef once in bytes dictionary builder
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 26, 2026
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.
Fixes #12424.
GenericByteDictionaryBuilder::get_or_insert_keyhashedvalue.as_ref()to look the value up, then calledvalue.as_ref()a second time inside the insert closure throughstorage.append_value(value).AsRefis not required to be idempotent, so the stored bytes could differ from the bytes that were hashed: the dictionary then holds a value filed under the wrong hash, and a later append of the value that was actually hashed adds a duplicate entry.The builder now stores the same
&T::Nativethat it hashed. This is the same fix #12397 made forFixedSizeBinaryDictionaryBuilder, which had the identical pattern.Verification:
test_dictionary_builder_hashes_and_stores_the_same_bytesuses anAsRef<str>that returns a different value on each call; onmainit fails withleft: 2, right: 1(the dictionary ends up with two entries and keys[0, 1]instead of one entry with[0, 0]). It passes with this change.cargo test -p arrow-array: 767 passed, 1 ignored.cargo fmt --all -- --checkandcargo clippy -p arrow-array --all-targets --all-features -- -D warningsare clean.The text above was drafted with an AI assistant; I ran the tests myself.