zstd_in_out: Zstd file substitution for input

zstd_inR Documentation

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(),
  max_output_bytes = NULL
)

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

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

Intermediate file path used during conversion. It is removed on exit, whether supplied or auto-generated.

max_output_bytes

Optional maximum number of decompressed output bytes passed through to zstd_decompress_file().

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.

Value

The value returned by FUN.

The value returned by FUN, with its visibility preserved.

Examples

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))
}

qs2 documentation built on April 22, 2026, 9:07 a.m.