klion26 commented on code in PR #8357:
URL: https://github.com/apache/arrow-rs/pull/8357#discussion_r2354157130
##########
parquet-variant/src/utils.rs:
##########
@@ -144,3 +144,20 @@ pub(crate) const fn expect_size_of<T>(expected: usize) {
let _ = [""; 0][size];
}
}
+
+pub(crate) fn fits_precision<const N: u32>(n: impl Into<i64>) -> bool {
Review Comment:
Thanks for the detailed reply, I'm fine with the current implementation
##########
parquet-variant/src/variant.rs:
##########
@@ -1096,13 +1096,21 @@ impl<'m, 'v> Variant<'m, 'v> {
/// let v2 = Variant::from(std::f64::consts::PI);
/// assert_eq!(v2.as_f16(), Some(f16::from_f64(std::f64::consts::PI)));
///
+ /// // and from integers with no more than 11 bits of precision
Review Comment:
Maybe we need to update the doc(the comment said that -- Returns
`Some(f16)` for float and double variants, `None` for non-floating-point
variants) or add an example for integer overflow (`Variant::from(2048) for f16
-- will return None)
I don't have a strong preference here, it's just an idea that popped into my
mind when I saw this
--
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]