rich7420 commented on code in PR #7802:
URL: https://github.com/apache/datafusion-comet/pull/7802#discussion_r4760822630
##########
native/spark-expr/src/conversion_funcs/numeric.rs:
##########
@@ -965,7 +965,8 @@ pub(crate) fn decimal128_to_f64(unscaled: i128, scale: i8)
-> f64 {
// Fast path (also Java's): when the unscaled value and the power of ten
are both exact
// doubles, a single IEEE division or multiplication is correctly rounded.
if unscaled.unsigned_abs() <= F64_EXACT_INT_LIMIT {
- let m = unscaled as f64;
+ // The exactness bound also lets us use a native-width integer
conversion.
+ let m = (unscaled as i64) as f64;
Review Comment:
For `scale == 0`, checking that all batch values fit `i64` made
`decimal18_to_f64` about 3.4x faster on my arm64 machine. Worth adding?
##########
native/spark-expr/benches/cast_numeric.rs:
##########
@@ -108,6 +109,33 @@ fn criterion_benchmark(c: &mut Criterion) {
});
}
group.finish();
+
+ let mut group = c.benchmark_group("cast_decimal_scaled");
+ for (name, cast, limit) in [
+ ("f64", &decimal_to_f64, 1_i128 << 53),
+ ("f32", &decimal_to_f32, 1_i128 << 24),
+ ] {
+ for (shape, bound, null_rate) in [
+ ("exact", limit, 0.0),
+ ("exact_nulls", limit, 0.1),
+ ("exact_dense_nulls", limit, 0.8),
Review Comment:
`exact_nulls` and `exact_dense_nulls` time about the same for me, since
`unary` maps every slot. Maybe drop the dense one?
--
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]