scovich opened a new pull request, #12420: URL: https://github.com/apache/arrow-rs/pull/12420
# Which issue does this PR close? - Related to #12318 and #8794 # Rationale for this change There's no really clean way to clone a `&dyn Array`. The two most common workarounds are: * `make_array(array.to_data())` * `array.slice(0, array.len())` The latter is cheaper than the former, but both do extra work and both are roundabout ways of obtaining a shallow copy of an array. # What changes are included in this PR? New `Array::to_arc` method that returns a shallow clone of its receiver: * Provided impl is `self.slice(0, self.len())`, to avoid a breaking change * Concrete `T: Array` does `Arc::new(self.clone())` * `ArrayRef` does `Arc::clone(self)` * Wrapper types (`&T`, `TypedDictionaryArray`, `TypedRunArray`) forward to the underlying type Several call sites that were relying on workarounds are updated to use the new method. # Are these changes tested? A new unit test validates each flavor of implementation. I'm on the fence about how much value it really adds, but it's only ~20 LoC so I kept it. # Are there any significant user-facing changes? See above. # AI usage disclosure This PR is a significantly cleaned up version of a vibe-coded rough draft. The PR description is mine alone, and I can answer for every line of the diff. -- 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]
