You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jhorstmann (via GitHub)" <gi...@apache.org> on 2023/09/07 08:32:26 UTC

[GitHub] [arrow-rs] jhorstmann commented on a diff in pull request #4785: Replace usage of `lexical-core crate` with libcore for parsing strings as floats

jhorstmann commented on code in PR #4785:
URL: https://github.com/apache/arrow-rs/pull/4785#discussion_r1318272872


##########
arrow-json/src/reader/primitive_array.rs:
##########
@@ -57,19 +57,31 @@ primitive_parse!(i8, i16, i32, i64, u8, u16, u32, u64);
 
 impl ParseJsonNumber for f16 {
     fn parse(s: &[u8]) -> Option<Self> {
-        lexical_core::parse::<f32>(s).ok().map(f16::from_f32)
+        s.iter()
+            .map(|&b| b as char)
+            .collect::<String>()

Review Comment:
   Since this file is json specific it might also be possible to use `serde_json::from_slice(s).ok()`, but it seems this has slightly stricter parsing and does not accept numbers such as `2e0` as integer (but does as float).



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org