alamb commented on issue #6430: URL: https://github.com/apache/arrow-rs/issues/6430#issuecomment-2366736146
> In my opinion, can we define something like BooleanArrayMutator? I am still reading codes and thinking. I think we can use the builders for this rather than adding a new API. I think we can use the existing structures for low level manipulation we made it a bit easier to convert between them. I think we should make conversion from array --> builder such that they don't copy if possible, but if necessary copy the underlying buffers. A sliced array is likely to be share so copying the bitmap to modify it will be needed anyways > And for in-place modification, I found another challenge that we can't modify bit through index using BooleanBuilder? The lower level BooleanBufferBuilder contains the relevant APIs, like this: https://docs.rs/arrow/latest/arrow/array/builder/struct.BooleanBufferBuilder.html#method.set_bit Rather than changing BooleanBuilder to allow direct manipulation of the underling boolean buffer, maybe we could make it easier to further destructure it (see [source](https://docs.rs/arrow-array/53.0.0/src/arrow_array/builder/boolean_builder.rs.html#60-61)) For example ```rust // convert boolean array --> BooleanBuilder let builder = boolean_array.into_builder(); // Deconstruct the BooleanBuilder into `BooleanBufferBuilder` and `NullBufferBuilder let (bool_builder, null_builder) = builder.into_builders(); .. modify the boolean/null buffers via low level builders // put it back together let builder = BooleanBuilder::new_from_builders(bool_builder, null_builder); let array = builder.finish() ``` new_from_builders is inspired by https://docs.rs/arrow/latest/arrow/array/builder/struct.PrimitiveBuilder.html#method.new_from_buffer -- 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]
