compiler-segfault opened a new pull request, #12463: URL: https://github.com/apache/arrow-rs/pull/12463
Fixes #12424. `GenericByteDictionaryBuilder::get_or_insert_key` hashed `value.as_ref()` to look the value up, then called `value.as_ref()` a second time inside the insert closure through `storage.append_value(value)`. `AsRef` is 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::Native` that it hashed. This is the same fix #12397 made for `FixedSizeBinaryDictionaryBuilder`, which had the identical pattern. Verification: - New test `test_dictionary_builder_hashes_and_stores_the_same_bytes` uses an `AsRef<str>` that returns a different value on each call; on `main` it fails with `left: 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 -- --check` and `cargo clippy -p arrow-array --all-targets --all-features -- -D warnings` are clean. The text above was drafted with an AI assistant; I ran the tests myself. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
