/ vctrs Public
Revert to a simpler ownership model - but always duplicate ALTREP #1151
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge.
Reverts back to a slightly simpler ownership model of
When we own the object, we only ever attempt to duplicate it if it is ALTREP. If
vec_init()ever creates ALTREP objects in the future (#837), this will be required. When doing assignment, we have to duplicate ALTREP objects before dereferencing even if we own them, because we need access to the actual data that it is representing, not the ALTREP object's internals.
When we don't own the object, we use
r_clone_referenced()to determine if we need to duplicate or not.
This fixed the repeated duplication that was occurring in
df_assign()'s calls to
vec_proxy_assign_opts(), but I then discovered that we still had repeated duplication in
vec_restore(). To fix that, I had to borrow from the ideas in #1124 and pass through
vec_restore()as well. This allows us to avoid attempting duplication here as well.
With both of those in place, tidyverse/dplyr#5327 is fixed:
It is worth noting that @lionel- and I both think that eventually we should probably have recursive proxy and restore functions (#1107). This would allow
df_assign()to not have to proxy and restore the output columns repeatedly, which is where many of these duplication issues arise. That would also allow us to remove the
vec_restore()again, which I am currently viewing as a temporary fix.
This also closes #1124, because it fixes the original problem there where columns of df-cols were being duplicated.