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

   > Each call will require at least one memory allocation, even in the fast 
case.
   
   What if you made `shrink_to_fit` consuming. Something like this:
   
   ```rust
   impl Array for BooleanArray {
       …
       fn shrink_to_fit(self) -> Self {
           Self{
               values: self.values.shrink_to_fit(),
               nulls: self.nulls.as_ref().map(|b| b.shrink_to_fit()),
           }
       }
   }
   ```
   
   Then if you already had an owned array no clone would be required at all.
   
   It would take some finagling to get this out of an ArrayRef - maybe 
something like
   
   ```rust
   let arr: ArrayRef  = ...;
   if let bool_array_arc: Arc<BooleanArray> = arr.downcast() {
     bool_array_arc.unwrap_or_clone().shrink_to_fit()
   }
    ```
   
   Though I suppose you still need to rewrap into an Arc to get an array ref 🤔 
     


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