Skip to contents

Functions to check ownership or disown simulation output files on disk.

Usage

ownership()

list_ownership(full.names = FALSE)

check_ownership(x)

disown(x)

take_ownership(x)

Arguments

full.names

if TRUE, include the directory path when listing file ownership.

x

an mrgsimsds object.

Value

  • check_ownership: TRUE if x owns the underlying files; FALSE otherwise.

  • list_ownership: a data.frame of ownership information.

  • ownership: nothing; used for side effects.

  • disown: x is returned invisibly; it is not modified.

  • take_ownership: x is returned invisibly after getting modified in place.

Details

One situation were you need to take over ownership is when you are simulating in parallel, and the simulation happens in another R process. mrgsim.ds ownership is established when the simulation returns and the mrgsimsds object is created. When this happens in another R process (e.g., on a worker node, there is no way to transfer that information back to the parent process. In that case, a call to take_ownership() once the results are returned to the parent process would be appropriate. Typically, these results are returned as a list and a call to reduce_ds() will create a single object pointing to and owning multiple files. Therefore, it should be rare to call take_ownership() directly; if doing so, please make sure you understand what is going on.

See also

Examples

mod <- house_ds()

out <- mrgsim_ds(mod, id = 1)

check_ownership(out)
#> [1] TRUE

ownership()
#> > Objects: 7 | Files: 7 | Size: 350.3 Kb

list_ownership()
#>                              file        address
#> 1 mrgsims-ds-1b914460a94c.parquet 0x555e19729940
#> 2                 example.parquet 0x555e1791abb0
#> 3 mrgsims-ds-1b9165f2b26f.parquet 0x555e15335db8
#> 4            mrgsims-ds-1.parquet 0x555e19d47160
#> 5 mrgsims-ds-1b911d4f2d4b.parquet 0x555e0df4ac40
#> 6 mrgsims-ds-1b911cc532ed.parquet 0x555e1067ece8
#> 7 mrgsims-ds-1b917c8416e2.parquet 0x555e0889f788

e1 <- ev(amt = 100)
e2 <- ev(amt = 200)

out <- list(mrgsim_ds(mod, e1), mrgsim_ds(mod, e2))

sims <- reduce_ds(out)

ownership()
#> > Objects: 8 | Files: 9 | Size: 403.5 Kb

check_ownership(sims)
#> [1] TRUE

check_ownership(out[[1]])
#> [1] FALSE

check_ownership(out[[2]])
#> [1] FALSE