Dandandan commented on issue #7455:
URL: https://github.com/apache/arrow-rs/issues/7455#issuecomment-2839697188

   Let me start with collecting a list of possible replacements of 
`MutableArray` vs `Vec`-based construction and faster generally faster way of 
doing things, so we could convert it 
   
   Vec-based API
   
   | Old | Vec-based |
   | -------- | ------- |
   | `MutableBuffer::new(size * std::mem::size_of::<T>())` | 
`Vec<T>::with_capacity(size)` |
   | `BufferBuilder` | `Vec`
   | `Buffer::from_trusted_len_iter` | `Iterator::collect` (into `Vec`) - this 
doesn't use `unsafe` and is as fast |
   | Primitive builders |  Use `Vec<T>` (Iterator::collect) and build nulls 
separately (via `BooleanBuffer::collect_bool` if possible)  |
   | Byte buikder |  Use `Vec<T>`, `Vec<Offset> (Iterator::collect) and build 
nulls separately (via `BooleanBuffer::collect_bool` if possible)  |
   
   
   Faster versions
   
   
   | Slower | Faster |
   | -------- | ------- |
   | `MutableBuffer::push` or `Vec::push` | `extend` or `collect` |
   |  `vec![]` or `MutableBuffer::new(0) | `Vec::with_capacity` (preallocate 
once for known capacity) |
   |  `NullBufferBuilder` or  boolean buffer builder | 
`BooleanBuffer::collect_bool` |
   
   
   
   


-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to