Learn R Programming

qs2 (version 0.1.7)

zstd_in: Zstd file substitution for input

Description

Substitutes a zstd compressed file for a regular input file. The zstd compressed file is decompressed to the input FUN.

Substitutes a zstd compressed file for a regular output file. The output of FUN is converted to a zstd compressed file at the target zstd file path.

Usage

zstd_in(FUN, ..., envir = parent.frame(), tmpfile = tempfile())

zstd_out(FUN, ..., envir = parent.frame(), tmpfile = tempfile())

Value

The value returned by FUN.

The value returned by FUN, with its visibility preserved.

Arguments

FUN

Function to call.

...

Arguments passed to FUN. The first named argument is treated as the file path.

envir

Environment for FUN evaluation.

tmpfile

Temporary file path. If not supplied, a temp file is created and removed on exit.

Details

This is a generic wrapper that works with any function that reads from a file.

This is a generic wrapper that works with any function that writes to a file.

Examples

Run this code
if (requireNamespace("data.table", quietly = TRUE)) {
  zfile <- tempfile(fileext = ".csv.zst")
  zstd_out(data.table::fwrite, mtcars, file = zfile)
  dt <- zstd_in(data.table::fread, file = zfile)
  print(nrow(dt))
}

Run the code above in your browser using DataLab