lazySave: Save objects to a 'lazyR' database

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function creates an archivist repository that holds metadata ("tags") associated with the object. Unlike the archivist package, the objects themselves are saved as lazy load databases (i.e., via tools:::makeLazyLoadDB). Each object is saved into its own lazy load database, with a filename that matches the object name. Because it is also an archivist repository, lazy loading of objects can be done via tags, classes etc..

Usage

1
2
3
lazySave(..., objNames = NULL, lazyDir = NULL, tags = NULL,
  clearRepo = FALSE, overwrite = FALSE, copyRasterFile = TRUE,
  compareRasterFileLength = 1e+06)

Arguments

...

Objects to save to an R lazy database, with metadata saved via archivist package repository.

objNames

Optional vector of names of same length as ... to override the object names.

lazyDir

Character string of directory to be used for the lazy databases. This creates an archivist repository.

tags

Character vector of additional tags to add to the objects being saved

clearRepo

Logical. Should the repository be deleted before adding new objects

overwrite

Logical. Should new object replace (i.e., overwrite) previous object with same name

copyRasterFile

Logical. Should the source file for rasters be copied into the lazyDir. Default TRUE, which may be slow. See Details.

compareRasterFileLength

Numeric. This is passed to the length arg in digest when determining if the Raster file is already in the database. Default 1e6. See Details.

Details

The main use case for this is large, complicated datasets, such as GIS databases, that are used within R. Loading them lazily means that the user can have access to all of them, including their characteristics, without loading them all first (could be very slow). When copyRasterFile is TRUE, it may take a while as the original source file is copied. Also, the slot in the raster file that indicates the file pointer is switched to new location. This allows more modular lazyR database, i.e., if the Raster files are copied into the lazyR database, then the whole database contains everything needed to copy to another machine. Note: If copyRasterFile is TRUE, but the file is already there and is identical (using digest), then no copy is done.

When copyRasterFile is TRUE, it will actually run a digest command on the file, if it already exists in the rasters directory of the lazyR database. If this hash resulting from the digest indicates that the file is already there and it is identical, then it will not actually be copied. This will be good for speed, but will miss small changes in files. Set compareRasterFileLength to Inf if truly exact comparisons behaviour is needed.

Value

invisibly returns a character vector of objects saved.

Author(s)

Eliot McIntire

See Also

lazyLs, lazyRm, lazyLoad2.

Examples

1
2
3
4
5
6
7
8
9
a <- rnorm(10)
b <- rnorm(20)
lazyDir(file.path(tempdir(),"lazyDir"), create=TRUE)
lazySave(a, b)
## Not run:  # may be many objects
lazySave(mget(ls(envir=.GlobalEnv)))
unlink(file.path(tempdir(), "lazyDir"), recursive=TRUE)

## End(Not run)

PredictiveEcology/lazyR documentation built on May 8, 2019, 3:10 p.m.