tustvold commented on code in PR #5101:
URL: https://github.com/apache/arrow-rs/pull/5101#discussion_r1399443163


##########
arrow-json/src/reader/string_array.rs:
##########
@@ -61,7 +61,15 @@ impl<O: OffsetSizeTrait> ArrayDecoder for 
StringArrayDecoder<O> {
                 TapeElement::Number(idx) if coerce_primitive => {
                     data_capacity += tape.get_string(idx).len();
                 }
-                _ => return Err(tape.error(*p, "string")),
+                TapeElement::I64(n) | TapeElement::I32(n) if coerce_primitive 
=> {
+                    data_capacity += n.to_string().len();
+                }
+                TapeElement::F32(n) | TapeElement::F64(n) if coerce_primitive 
=> {
+                    data_capacity += n.to_string().len();
+                }

Review Comment:
   ```suggestion
                   TapeElement::I64(n) | TapeElement::I32(n) | 
TapeElement::F32(n) | TapeElement::F64(n) => {
                       data_capacity += 10; // An arbitrary estimate
                   }
   ```
   
   This avoids serializing to a string multiple times, this could be improved 
if it becomes a bottleneck, but this is probably good enough



-- 
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]

Reply via email to