raghavyadav01 opened a new pull request, #27780:
URL: https://github.com/apache/datafusion/pull/27780

   ## Which issue does this PR close?
   
   - Closes #27727.
   
   ## Rationale for this change
   
   With `perfect_hash_join_min_key_density = 0` (or a large 
`perfect_hash_join_small_build_threshold`), a perfect hash join can be chosen 
for any key range. The memory reservation succeeds with the default unbounded 
pool, and `vec![0; range + 1]` then panics with `capacity overflow` past 
`isize::MAX` bytes, or aborts the process when the allocator refuses a smaller 
but still huge map.
   
   ## What changes are included in this PR?
   
   - `array_map_key_range` skips the `ArrayMap` when `(range + 1) * 4` bytes 
exceeds `isize::MAX`, so the join falls back to the hash map instead of 
panicking.
   - `ArrayMap::try_new` allocates with `try_reserve_exact`, so a map the 
allocator cannot provide returns `ResourcesExhausted` instead of aborting.
   
   Filling with zeros after `try_reserve_exact` writes the slots that `vec![0; 
n]` left to the OS. With the default thresholds the map has at most ~6.7 slots 
per build row, so the cost stays proportional to the build side.
   
   ## Are these changes tested?
   
   - A `joins.slt` case with the issue's 2^62 range and 
`perfect_hash_join_min_key_density = 0` (panicked before, returns `0 0` now).
   - A unit test that `ArrayMap::try_new` over a 2^60 range returns 
`ResourcesExhausted` (aborted before).
   
   ## Are there any user-facing changes?
   
   No.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to