Skip to content

Add a reusable caching array hasher - #26817

Open
Rich-T-kid wants to merge 2 commits into
apache:mainfrom
Rich-T-kid:scatter-dictionary-hashes
Open

Rich-T-kid wants to merge 2 commits into
apache:mainfrom
Rich-T-kid:scatter-dictionary-hashes

Conversation

@Rich-T-kid

@Rich-T-kid Rich-T-kid commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #26780.

Rationale for this change

Hash operators repeatedly see dictionary batches that share one values array. Rehashing those values for every batch wastes work; only the new keys need to be scattered.

What changes are included in this PR?

Add CachingArrayHasher. One hasher corresponds to one hash expression and owns the hash seed, a weak dictionary-values identity, and a reusable value-hash buffer. Ordinary arrays keep the existing hashing path. Dictionary arrays reuse their value hashes while the values Arc is unchanged and refill the same allocation when it changes.

dictionary_hashes exposes the current values and hashes for aggregation, and size reports the cached allocation.

What is the testing strategy for this PR?

One focused test covers the same-values-Arc cache hit with composite-key rehashing, dictionary replacement, allocation reuse, null dictionary values, and the non-dictionary fallback. The focused normal and collision-mode hash tests pass on the rebased head, along with workspace Clippy, formatting, and typo checks.

Are there any user-facing changes?

No.

@github-actions github-actions Bot added the common Related to common crate label Oct 27, 2026
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch 2 times, most recently from ec3f074 to 093c6fa Compare October 27, 2026 18:46
@Rich-T-kid
Rich-T-kid marked this pull request as ready for review October 27, 2026 18:46
@Rich-T-kid
Rich-T-kid marked this pull request as draft October 27, 2026 18:47
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 093c6fa to 02f9d0a Compare October 27, 2026 18:58
@Rich-T-kid
Rich-T-kid marked this pull request as ready for review October 27, 2026 19:01
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 02f9d0a to 1b38458 Compare October 27, 2026 19:02
@Rich-T-kid

Rich-T-kid commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@kumarUjjawal @jayzhan-synnada small change but should make the follow on PR's less bloated.

@Rich-T-kid
Rich-T-kid marked this pull request as draft October 27, 2026 19:02
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 1b38458 to 92e9e15 Compare October 27, 2026 19:03
@Rich-T-kid
Rich-T-kid marked this pull request as ready for review October 27, 2026 19:13
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch 2 times, most recently from 752283a to 4ede583 Compare October 27, 2026 19:26
@Rich-T-kid Rich-T-kid changed the title Expose dictionary hash scattering in hash_utils Expose hash helpers for dictionary caching Oct 27, 2026
@Rich-T-kid
Rich-T-kid marked this pull request as draft October 27, 2026 19:27
@Rich-T-kid
Rich-T-kid marked this pull request as ready for review October 27, 2026 19:35
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 4ede583 to 9f6f79f Compare October 28, 2026 02:25
@Rich-T-kid Rich-T-kid changed the title Expose hash helpers for dictionary caching Add a reusable dictionary hash cache Oct 28, 2026
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 9f6f79f to 2bbdcbc Compare October 28, 2026 04:12
@Rich-T-kid Rich-T-kid changed the title Add a reusable dictionary hash cache Add a reusable array hash cache Oct 28, 2026
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 2bbdcbc to 1e48c85 Compare October 28, 2026 04:15
@Rich-T-kid Rich-T-kid changed the title Add a reusable array hash cache Add a reusable caching array hasher Oct 28, 2026
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 1e48c85 to 23f953d Compare October 28, 2026 04:27
Reuse dictionary value hashes while the values Arc is unchanged so operators do not rehash the same dictionary for every batch.
@Rich-T-kid
Rich-T-kid force-pushed the scatter-dictionary-hashes branch from 1284065 to 0490700 Compare October 28, 2026 04:52
@kumarUjjawal

Copy link
Copy Markdown
Contributor

@Rich-T-kid I see you're still working on this, can you ping me when its ready for me to look at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants