Learn R Programming

JWileymisc (version 1.4.1)

compressed RDS: Save and read RDS functions for using multithreaded “ZSTD” or “LZ4” compression

Description

Save and read RDS functions for using multithreaded “ZSTD” or “LZ4” compression

Usage

saveRDSfst(object, filename = "", compression = 100, algorithm = "ZSTD")

readRDSfst(filename)

Value

saveRDSfst() is called for its side effect of saving a file to disk. The original R object if using readRDSfst().

Arguments

object

An R object to be saved.

filename

A character string giving the filename of the object on disk (to save to or read from)

compression

A numeric value between 0 and 100 indicating the amount of compression. Defaults to 100, the highest level of compression. 0 gives the lowest compression.

algorithm

A character string of the type of compression to use. Defaults to “ZSTD” which is better compression but slower. The only other option is “LZ4” which is faster but may provide less compression.

Details

By default, saveRDS() does not have multithreaded compression built in. These functions use “ZSTD” or “LZ4” compression via the fst package for multithreaded compression and decompression with good performance. To save them, objects are serialized, compressed, and then saved using saveRDS(). To read them, objects are read in using readRDS(), decompressed, and then unserialized. Hashing is used to verify the results. saveRDS() is performed using version = 3, so it will not work on older versions of R.

Examples

Run this code

saveRDSfst(mtcars, filename = file.path(tempdir(), "mtcars.RDS"))

saveRDSfst(mtcars, filename = file.path(tempdir(), "mtcars.RDS"))
readRDSfst(file.path(tempdir(), "mtcars.RDS"))

Run the code above in your browser using DataLab