jaideeppyne opened a new pull request, #10567:
URL: https://github.com/apache/arrow-rs/pull/10567

   # Which issue does this PR close?
   
   - Closes #10523.
   
   # Rationale for this change
   
   Decimal-to-float and floating-point-to-decimal casts recompute `10^scale` 
with `f64::powi`. Valid Arrow decimal scales are bounded by 
`Decimal256Type::MAX_SCALE`, so these powers can be looked up instead.
   
   # What changes are included in this PR?
   
   - Store the exact IEEE-754 results of `10_f64.powi(0..=76)` in one shared 
table.
   - Use that table in both decimal/float cast directions.
   - Retain `powi` for negative or out-of-range scales, preserving existing 
behavior outside the table.
   - Add an exhaustive test proving bit-for-bit equality with the prior 
calculation across every valid signed decimal scale.
   
   # Are these changes tested?
   
   - `cargo test -p arrow-cast test_decimal_f64_power_matches_powi --lib` — 1 
passed.
   - `cargo test -p arrow-cast cast:: --lib` — 326 passed.
   - `cargo clippy -p arrow-cast --all-targets --all-features -- -D warnings` — 
passed.
   - `cargo +stable fmt --all -- --check` — passed.
   
   A local optimized microbenchmark performed 100 million calculations while 
cycling through scales 0–38. Two runs measured:
   
   | implementation | run 1 | run 2 |
   | --- | ---: | ---: |
   | `10_f64.powi(scale)` | 198.5 ms | 159.7 ms |
   | lookup | 61.0 ms | 60.7 ms |
   
   This isolates the scale calculation rather than claiming an end-to-end cast 
speedup. Both variants produced the same accumulated result.
   
   # Are there any user-facing changes?
   
   No API or output change is intended. The equality regression test covers all 
valid decimal scales.
   
   ## AI assistance disclosure
   
   Codex assisted Jaideep Pyne with code generation, repository investigation, 
and PR drafting. Jaideep Pyne is the human operator responsible for the 
submission; the change was validated with the commands and measurements above.
   


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