scovich commented on PR #12318: URL: https://github.com/apache/arrow-rs/pull/12318#issuecomment-7102468330
> a more general solution would be to figure a way to recover `ArrayRef` from `&dyn Array`, and there was some prior art for it here... but I guess it stalled > The more I see this the more I am thinking the `to_arc()` API would help a lot to avoid calling make_array 🤔 > `to_arc` (just cloning) should also be slightly faster than `slice` as slicing `NullBuffer` does a popcount, and I didn't find any good way to avoid that without regressing all `NullBuffer::slice` calls. I was trying to actually _recover_ the Arc from a `&dyn Array`, but that's just not possible in the common case (**). If the goal is merely to specialize `Array::slice` as `Array::to_arc`, that should be quite straightforward (***). I'd be tempted to call it`Array::clone_as_arc` since that's what it actually does, but that doesn't roll off the tongue as nicely as `to_arc` and the other `to_foo` helpers already set a precedent for simpler naming. (**) Of course, `impl Array for ArrayRef` should return `Arc::clone(self)`, and `impl<T: Array> Array for &T` should forward to underlying... but most call sites really do pass `ArrayRef::as_ref()` and there's no way to recover the original arc. (***) I didn't explore the possibility of `Array::slice` as a starting point before. -- 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]
