auto_clear_lazyarray: Automatically remove array data

Description Usage Arguments Details Author(s) Examples

View source: R/lazyarray.R

Description

Remove the files containing array data once no 'lazyarray' instance is using the folder. Require installation of dipsaus package (at least version 0.0.8).

Usage

1

Arguments

x

'lazyarray' instance

onexit

passed to reg.finalizer

Details

auto_clear_lazyarray attempts to remove the entire folder containing array data. However, if some files are not created by the array, only partition data and meta file will be removed, all the artifacts will remain and warning will be displayed. One exception is if all files left in the array directory are *.meta files, all these meta files will be removed along with the folder.

Author(s)

Zhengjia Wang

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
path <- tempfile()
arr_dbl <- lazyarray(path, storage_format = 'double',
                     dim = 2:4, meta_name = 'meta-dbl.meta')
arr_dbl[] <- 1:24
auto_clear_lazyarray(arr_dbl)

arr_chr <- lazyarray(path, storage_format = 'character',
                     dim = 2:4, meta_name = 'meta-chr.meta',
                     quiet = TRUE)
auto_clear_lazyarray(arr_chr)

# remove either one, the directory still exists
rm(arr_dbl); invisible(gc(verbose = FALSE))

arr_chr[1,1,1]

# Remove the other one, and path will be removed
rm(arr_chr); invisible(gc(verbose = FALSE))

dir.exists(path)
arr_check <- lazyarray(path, storage_format = 'character',
                       dim = 2:4, meta_name = 'meta-chr',
                       quiet = TRUE)

# data is removed, so there should be no data (NAs)
arr_check[]

lazyarray documentation built on July 18, 2020, 9:06 a.m.