HaoYang670 opened a new issue, #1640:
URL: https://github.com/apache/arrow-rs/issues/1640

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   Currently, when users what to create an array by using `ArrayDataBuilder`, 
they always write code like:
   ```rust
   let data_buffer = ...;
   let offsets_buffer = ...;
   let validity_buffer = ...;
   let array_data = ArrayData::builder(datatype)
       .len(num_of_element)
       .null_bit_buffer(validity_buffer)
       .add_buffer(offsets_buffer)
       .add_buffer(data_buffer)
       .offset(number)
       .build()
       .unwrap();
   ```
   The code is not user-friendly and easy to cause some runtime errors. Because:
   1. Users have to remember the order and type of each buffer: 
https://arrow.apache.org/docs/format/Columnar.html#buffer-listing-for-each-layout
   2. The array can have at most 3 buffers, but by using the method 
`add_buffer` or `buffers`, users can create arrayData with > 3 buffers, which 
is harmful.
   
   
   **Describe the solution you'd like**
   1. delete the methods `add_buffer` and `buffers`
   2. add methods `offsets_buffer`, `type_ids_buffer` and `data_buffer`
   3. rename `null_bit_buffer` and `validity_buffer` (because it is the name in 
Apache Arrow Format)
   4. Update the struct of `ArrayDataBuilder` like:
   ```rust
   pub struct ArrayDataBuilder {
       data_type: DataType,
       len: usize,
       null_count: Option<usize>,
       validity_buffer: Option<Buffer>,
       offsets_buffer: Option<Buffer>,
       type_ids_buffer: Option<Buffer>,
       data_buffer: Option<Buffer>,
       offset: usize,
       child_data: Vec<ArrayData>,
   }
   ```
   (we can do add some cheap checking in the `build` method)
   
   This will introduce some public API changes. So I want more code maintainers 
to review this issue. And I will implement this if we could reach consensus.


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