mbutrovich commented on PR #11467: URL: https://github.com/apache/arrow-rs/pull/11467#issuecomment-6427510100
To check that the API works in a kernel, I prototyped integer `/` and `%` by a scalar in `arrow_arith::numeric` on top of this PR, with two ways to match on the variants once. - A macro generates one function per type, which matches on that type's variants and calls `unary`. `arithmetic_op` calls it for `Int32`, `Int64`, `UInt32` and `UInt64` before `integer_op`, which can't match on per-type variants because it is generic. - A visitor: the divisor matches on its own variants and passes the variant to a generic visitor, which needs four new sealed traits in `arrow-buffer`. On an Apple M5 Max with the `integer_division` benchmark from #11427, the two were within 4% of each other in all 28 cases, in the default and thin LTO builds, and 1.2-13.5x faster than `main`. Since they perform the same, I'd use the macro and keep this PR's API as it is, without the traits. The cost is that each kernel lists each type's variants, and because the enums are `#[non_exhaustive]`, a variant added later reaches the kernel's wildcard arm, which matches on each value until the kernel lists it. -- 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]
