@@ -105,7 +105,7 @@ epix_fill_through_version = function(x, fill_versions_end,
105105# ' `y` individually, then performing a full join of the `DT`s on the non-version
106106# ' key columns (potentially consolidating multiple warnings about clobberable
107107# ' versions). If the `versions_end` values differ, the
108- # ' `versions_end_conflict ` parameter controls what is done.
108+ # ' `sync ` parameter controls what is done.
109109# '
110110# ' This function, [`epix_merge`], does not mutate its inputs and will not alias
111111# ' either archive's `DT`, but may alias other fields; `x$merge` will overwrite
@@ -115,16 +115,20 @@ epix_fill_through_version = function(x, fill_versions_end,
115115# ' old `DT` in another object).
116116# '
117117# ' @param x,y Two `epi_archive` objects to join together.
118- # ' @param versions_end_conflict Optional; `"stop"`, `"na"`, `"locf"`,
119- # ' or `"truncate"`; in the case that `x$versions_end` doesn't match
120- # ' `y$versions_end`, what do we do?: `"stop"`: emit an error; "na":
121- # ' use `max(x$versions_end, y$versions_end)`, but in the
122- # ' less up-to-date input archive, imagine there was an update immediately
123- # ' after its last observed version which revised all observations to be `NA`;
124- # ' `"locf"`: use `max(x$versions_end, y$versions_end)`,
125- # ' allowing the last version of each observation to be carried forward to
126- # ' extrapolate unavailable versions for the less up-to-date input archive; or
127- # ' `"truncate"`: use `min(x$versions_end, y$versions_end)`
118+ # ' @param sync Optional; `"forbid"`, `"na"`, `"locf"`, or `"truncate"`; in the
119+ # ' case that `x$versions_end` doesn't match `y$versions_end`, what do we do?:
120+ # ' `"forbid"`: emit an error; "na": use `max(x$versions_end, y$versions_end)`
121+ # ' as the result's `versions_end`, but ensure that, if we request a snapshot
122+ # ' as of a version after `min(x$versions_end, y$versions_end)`, the
123+ # ' observation columns from the less up-to-date archive will be all NAs (i.e.,
124+ # ' imagine there was an update immediately after its `versions_end` which
125+ # ' revised all observations to be `NA`); `"locf"`: use `max(x$versions_end,
126+ # ' y$versions_end)` as the result's `versions_end`, allowing the last version
127+ # ' of each observation to be carried forward to extrapolate unavailable
128+ # ' versions for the less up-to-date input archive (i.e., imagining that in the
129+ # ' less up-to-date archive's data set remained unchanged between its actual
130+ # ' `versions_end` and the other archive's `versions_end`); or `"truncate"`:
131+ # ' use `min(x$versions_end, y$versions_end)` as the result's `versions_end`,
128132# ' and discard any rows containing update rows for later versions.
129133# ' @param compactify Optional; `TRUE`, `FALSE`, or `NULL`; should the result be
130134# ' compactified? See [`as_epi_archive`] for an explanation of what this means.
@@ -151,7 +155,7 @@ epix_fill_through_version = function(x, fill_versions_end,
151155# ' @importFrom data.table key set
152156# ' @export
153157epix_merge = function (x , y ,
154- versions_end_conflict = c(" stop " ," na" ," locf" ," truncate" ),
158+ sync = c(" forbid " ," na" ," locf" ," truncate" ),
155159 compactify = TRUE ) {
156160 if (! inherits(x , " epi_archive" )) {
157161 Abort(" `x` must be of class `epi_archive`." )
@@ -161,7 +165,7 @@ epix_merge = function(x, y,
161165 Abort(" `y` must be of class `epi_archive`." )
162166 }
163167
164- versions_end_conflict <- rlang :: arg_match(versions_end_conflict )
168+ sync <- rlang :: arg_match(sync )
165169
166170 if (! identical(x $ geo_type , y $ geo_type )) {
167171 Abort(" `x` and `y` must have the same `$geo_type`" )
@@ -192,24 +196,24 @@ epix_merge = function(x, y,
192196 # preprocessing using non-mutating (but potentially aliasing) functions. This
193197 # approach potentially uses more memory, but won't leave behind a
194198 # partially-mutated `x` on failure.
195- if (versions_end_conflict == " stop " ) {
199+ if (sync == " forbid " ) {
196200 if (! identical(x $ versions_end , y $ versions_end )) {
197201 Abort(paste(
198202 " `x` and `y` were not equally up to date version-wise:" ,
199203 " `x$versions_end` was not identical to `y$versions_end`;" ,
200204 " either ensure that `x` and `y` are equally up to date before merging," ,
201- " or specify how to deal with this using `versions_end_conflict `"
202- ), class = " epiprocess__epix_merge_unresolved_versions_end_conflict " )
205+ " or specify how to deal with this using `sync `"
206+ ), class = " epiprocess__epix_merge_unresolved_sync " )
203207 } else {
204208 new_versions_end = x $ versions_end
205209 x_DT = x $ DT
206210 y_DT = y $ DT
207211 }
208- } else if (versions_end_conflict %in% c(" na" , " locf" )) {
212+ } else if (sync %in% c(" na" , " locf" )) {
209213 new_versions_end = max(x $ versions_end , y $ versions_end )
210- x_DT = epix_fill_through_version(x , new_versions_end , versions_end_conflict )$ DT
211- y_DT = epix_fill_through_version(y , new_versions_end , versions_end_conflict )$ DT
212- } else if (versions_end_conflict == " truncate" ) {
214+ x_DT = epix_fill_through_version(x , new_versions_end , sync )$ DT
215+ y_DT = epix_fill_through_version(y , new_versions_end , sync )$ DT
216+ } else if (sync == " truncate" ) {
213217 new_versions_end = min(x $ versions_end , y $ versions_end )
214218 x_DT = x $ DT [x [[" DT" ]][[" version" ]] < = new_versions_end , with = FALSE ]
215219 y_DT = y $ DT [y [[" DT" ]][[" version" ]] < = new_versions_end , with = FALSE ]
0 commit comments