mbutrovich opened a new pull request, #12422: URL: https://github.com/apache/arrow-rs/pull/12422
# Which issue does this PR close? - Closes #12173. - Part of #11421. # Rationale for this change Casts of `Timestamp` and `Duration` to a coarser unit divide every value by a ratio known only at run time, so each value takes a hardware divide. # What changes are included in this PR? - The two casts divide with `div_by_unit_ratio`, which matches the ratio against `MILLISECONDS`, `MICROSECONDS`, and `NANOSECONDS`. With a constant divisor, the compiler replaces each division with a multiply and a shift. - This is simpler than the `DivisorI64` that #12173 suggests, and the ratio is always one of those three constants. - `cast_time64_to_time32`, the third site in #12173, stays as it is. Each of its four instantiations has one caller that passes a constant divisor, and the release build already compiles its division to a multiply. - 5e759e5fd0 adds `Timestamp` and `Duration` unit casts to the `cast_timestamp` benchmark, with and without nulls, so the benchmark bot can compare against it. Casts to a finer unit multiply and don't change. # Are these changes tested? `test_cast_timestamp_and_duration_to_coarser_unit` in `arrow-cast/tests/cast/date_time.rs`. # Are there any significant user-facing changes? No. # AI usage disclosure I wrote this PR with help from Claude but understand and support the core approach, implementation, and test coverage. -- 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]
