EslamAhmed171 commented on PR #48710:
URL: https://github.com/apache/arrow/pull/48710#issuecomment-6885057960

   > @EslamAhmed171 Sorry for the delayed review! Are you still interested in 
working on this PR? If so, could you please address the feedback above and 
rebase your branch against the latest `main`? Thanks!
   
   Thanks for the review!
   
   I revisited the implementation and found it had several false-positive 
rejections, ranges that are perfectly valid but were being rejected because 
intermediate computations overflowed `int64_t`. I've reworked the computation 
to be done entirely in `uint64_t`, and the byte-size computation now uses 
`MultiplyWithOverflow()` as you suggested.
   
   ## Cases that were previously rejected but are now accepted
   
   The old code computed the range and size in `int64_t` (`stop - start` and 
`(range + step - 1) / step` for positive steps, the mirrored form for negative 
steps), which overflows for wide ranges even when the resulting array is small:
   
   | Input | Old behavior | New behavior |
   |---|---|---|
   | `Arange(INT64_MIN, INT64_MAX, 1LL << 62)` | `Invalid` (overflow in `stop - 
start`) | `[-9223372036854775808, -4611686018427387904, 0, 
4611686018427387904]` |
   | `Arange(INT64_MAX, INT64_MIN, -(1LL << 62))` | `Invalid` | 
`[9223372036854775807, 4611686018427387903, -1, -4611686018427387905]` |
   | `Arange(10, 0, INT64_MIN)` | `Invalid` (`-step` overflows) | `[10]` |
   | `Arange(INT64_MAX, INT64_MIN, INT64_MIN)` | `Invalid` | 
`[9223372036854775807, -1]` |
   
   These are all covered by the new `TestArray.ArangeBoundaryValues` test; the 
rejection paths are covered by `TestArray.ArangeInvalidInputs`.
   
   Happy to get another round of review if anything else needs tightening.


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

Reply via email to