HaoYang670 commented on issue #2054:
URL: https://github.com/apache/arrow-rs/issues/2054#issuecomment-1190019478

   While working on #2104, I find it might be good to let users decide both the 
`value_capacity` and the number of elements:
   ```rust
   pub struct GenericBinaryBuilder<OffsetSize: OffsetSizeTrait> {
       value_builder: UInt8BufferBuilder,
       offsets_builder: BufferBuilder<OffsetSize>,
       bitmap_builder: BooleanBufferBuilder,
   }
   
   impl<OffsetSize: OffsetSizeTrait> GenericBinaryBuilder<OffsetSize> {
       /// Creates a new `GenericBinaryBuilder` with at least 
       /// `num_elements` binary slots in the array and
       /// `value_capacity` bytes in the values buffer.
       pub fn new(num_elements: Option<usize>, value_capacity: Option<usize>) 
-> Self {
           Self { 
               value_builder: 
UInt8BufferBuilder::new(value_capacity.unwrap_or(1024)), 
               offsets_builder: 
BufferBuilder::<OffsetSize>::new(num_elements.unwrap_or(1023) + 1), 
               bitmap_builder: 
BooleanBufferBuilder::new(num_elements.unwrap_or(1023) + 1) 
           }
       }
   ```


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