This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
Proposal: use Box<dyn Array>
instead of Arc<dyn Array>
#1036
Labels
investigation
Issues or PRs that are investigations. Prs may or may not be merged.
no-changelog
Issues whose changes are covered by a PR and thus should not be shown in the changelog
I am trying to improve the clone-on-write aspect of this crate.
One important aspect in this journey is how to handle
Arc<dyn Array>
. Let's go through this problem in detail. ConsiderInt32Array
, whose in-memory repr isthe size of this struct is quite small - e.g.
values
andvalidity
are already Arced.I.e. when we use
Arc<dyn Array>
, we do not gain much vsBox<dyn Array>
- what we are wrapping into theArc
is basicallyDataType
.For nested types, we have things like
again, the
Arc<dyn Array>
is not very helpful here, since the struct itself is quite small.The biggest advantage of
Arc<dyn Array>
is that it implementsClone
. However, I recently found thatBox<dyn Array>
can also be clone via the dyn-clone crate.The biggest advantage of
Box<dyn Array>
is that it would enableas_any_mut
- i.e. we can essentially do stuff likein this case bypassing the
MutableArray
API altogether. I.e. it saves us aArc::get_mut
to derefArc<dyn Array>
, and imo makes the API easier to use and follow.Any thoughts?
The text was updated successfully, but these errors were encountered: