alamb commented on issue #9059:
URL: https://github.com/apache/arrow-rs/issues/9059#issuecomment-3696564312

   Here is one potential change:
   
   ```diff
   diff --git a/parquet/src/arrow/array_reader/byte_view_array.rs 
b/parquet/src/arrow/array_reader/byte_view_array.rs
   index f881690f805..71e517ffb61 100644
   --- a/parquet/src/arrow/array_reader/byte_view_array.rs
   +++ b/parquet/src/arrow/array_reader/byte_view_array.rs
   @@ -162,11 +162,12 @@ impl ColumnValueDecoder for 
ByteViewArrayColumnValueDecoder {
                ));
            }
   
   -        let mut buffer = ViewBuffer::default();
   +        let num_values = num_values as usize;
   +        let mut buffer = ViewBuffer::with_capacity(num_values);
            let mut decoder = ByteViewArrayDecoderPlain::new(
                buf,
   -            num_values as usize,
   -            Some(num_values as usize),
   +            num_values,
   +            Some(num_values),
                self.validate_utf8,
            );
            decoder.read(&mut buffer, usize::MAX)?;
   diff --git a/parquet/src/arrow/buffer/view_buffer.rs 
b/parquet/src/arrow/buffer/view_buffer.rs
   index 2802f97f8f3..fab5a2488b9 100644
   --- a/parquet/src/arrow/buffer/view_buffer.rs
   +++ b/parquet/src/arrow/buffer/view_buffer.rs
   @@ -33,6 +33,14 @@ pub struct ViewBuffer {
    }
   
    impl ViewBuffer {
   +    /// Create a new ViewBuffer with capacity for the specified number of 
views
   +    pub fn with_capacity(capacity: usize) -> Self {
   +        Self {
   +            views: Vec::with_capacity(capacity),
   +            buffers: Vec::new(),
   +        }
   +    }
   +
        pub fn is_empty(&self) -> bool {
            self.views.is_empty()
        }
   @@ -111,7 +119,6 @@ impl ValuesBuffer for ViewBuffer {
   
    #[cfg(test)]
    mod tests {
   -
        use arrow_array::Array;
   
        use super::*;
   ```
   
   There were several other  places in the decoder where I wasn't sure if the 
`reserve` function was being called appropriately which should also be studied


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