Weijun-H commented on code in PR #9091:
URL: https://github.com/apache/arrow-rs/pull/9091#discussion_r2671427413
##########
arrow-json/src/reader/binary_array.rs:
##########
@@ -91,13 +155,15 @@ impl FixedSizeBinaryArrayDecoder {
impl ArrayDecoder for FixedSizeBinaryArrayDecoder {
fn decode(&mut self, tape: &Tape<'_>, pos: &[u32]) -> Result<ArrayData,
ArrowError> {
let mut builder = FixedSizeBinaryBuilder::with_capacity(pos.len(),
self.len);
+ let mut scratch = Vec::with_capacity(self.len as usize);
Review Comment:
Good catch. Here `self.len` comes from `DataType::FixedSizeBinary(len)` and
represents the decoded byte width per value, not the input hex string length.
The input string length is expected to be `2 * len` (or `2 * len - 1` for odd
digits). Using `Vec::with_capacity(self.len as usize)` preallocates the decoded
output size; for variable-width types we use `Vec::new()` and reserve per value
instead.
--
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]