Skip to content

Commit 1acc0ad

Browse files
committed
Add even more notes on aliasing&mutation in archive slide
1 parent 5491a93 commit 1acc0ad

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

R/grouped_epi_archive.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ grouped_epi_archive =
336336
# copies.
337337
if (address(as_of_archive$DT) == address(private$ungrouped$DT)) {
338338
# `as_of` aliased its the full `$DT`; copy before mutating:
339+
#
340+
# Note: this step is probably unneeded; we're fine with
341+
# aliasing of the DT or its columns: vanilla operations aren't
342+
# going to mutate them in-place if they are aliases, and we're
343+
# not performing mutation (unlike the situation with
344+
# `fill_through_version` where we do mutate a `DT` and don't
345+
# want aliasing).
339346
as_of_archive$DT <- copy(as_of_archive$DT)
340347
}
341348
dt_key = data.table::key(as_of_archive$DT)

R/methods-epi_archive.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,13 @@ group_by.epi_archive = function(.data, ..., .add=FALSE, .drop=dplyr::group_by_dr
805805
#' x$slide(new_var = comp(old_var), before = 119)
806806
#' ```
807807
#'
808-
#' Mutation and aliasing: `epix_slide` and `$slide` will not mutate the input
809-
#' archives, but may in some edge cases alias parts of the inputs, so copy the
810-
#' outputs if needed before using mutating operations like `data.table`'s `:=`
811-
#' operator. Currently, there should not be any aliasing encountered except for
812-
#' potentially aliasing of columns in edges cases with `all_versions = TRUE`,
813-
#' but this may change in the future.
808+
#' Mutation and aliasing: `epix_slide` and `$slide` will not perform in-place
809+
#' mutation of the input archives on their own. In some edge cases the inputs it
810+
#' feeds to the slide computations may alias parts of the input archive, so copy
811+
#' the slide computation inputs if needed before using mutating operations like
812+
#' `data.table`'s `:=` operator. Similarly, in some edge cases, the output of
813+
#' the slide operation may alias parts of the input archive, so similarly, make
814+
#' sure to clone and/or copy appropriately before using in-place mutation.
814815
#'
815816
#' @examples
816817
#' library(dplyr)

0 commit comments

Comments
 (0)