Calculate logarithm for Decimal64 values. For integer bases >= 2 with zero scale, return an exact integer log when the value is a perfect power of the base. Otherwise falls back to f64 computation.
(value: i64, scale: i8, base: f64)
| 128 | /// For integer bases >= 2 with zero scale, return an exact integer log when the |
| 129 | /// value is a perfect power of the base. Otherwise falls back to f64 computation. |
| 130 | fn log_decimal64(value: i64, scale: i8, base: f64) -> Result<f64, ArrowError> { |
| 131 | if scale == 0 |
| 132 | && is_valid_integer_base(base) |
| 133 | && let Ok(unscaled) = u64::try_from(value) |
| 134 | && unscaled > 0 |
| 135 | { |
| 136 | let base_u64 = base as u64; |
| 137 | let int_log = unscaled.ilog(base_u64); |
| 138 | if base_u64.checked_pow(int_log) == Some(unscaled) { |
| 139 | return Ok(int_log as f64); |
| 140 | } |
| 141 | } |
| 142 | decimal_to_f64(value, scale).map(|v| v.log(base)) |
| 143 | } |
| 144 | |
| 145 | /// Calculate logarithm for Decimal128 values. |
| 146 | /// For integer bases >= 2 with zero scale, return an exact integer log when the |
no test coverage detected
searching dependent graphs…