| Title: | Fast Object Serialization with High Compression |
|---|---|
| Description: | Quickly serialize R objects with high comopression using a custom serialization framework. Lossless transformation is performed on atomic types making them easier to compress; this means that compression can be better and faster than built-in methods. This package includes an implementation of the floating-point compression algorithm described in <doi:10.1145/3626717>. |
| Authors: | Mike Cheng [aut, cre, cph] |
| Maintainer: | Mike Cheng <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1.9002 |
| Built: | 2026-05-29 19:37:57 UTC |
| Source: | https://github.com/coolbutuseless/zap |
Count the uncompressed bytes to serialize this object
zap_count(x, opts = list(), ...)zap_count(x, opts = list(), ...)
x |
R object |
opts |
Named list of options. See |
... |
other named options to be included in |
Integer
zap_count(mtcars) length(zap_write(mtcars))zap_count(mtcars) length(zap_write(mtcars))
Create options list for writing data
zap_opts( transform, verbosity, lgl, int, fct, dbl, str, list, lgl_threshold, int_threshold, fct_threshold, dbl_threshold, str_threshold, dbl_fallback, ... )zap_opts( transform, verbosity, lgl, int, fct, dbl, str, list, lgl_threshold, int_threshold, fct_threshold, dbl_threshold, str_threshold, dbl_fallback, ... )
transform |
Enable transformations? Default: TRUE. Setting to FALSE will disable all transformations. |
verbosity |
Verbosity level. Default: 0 (no text output).
|
lgl |
transformation method for logical vectors. Default: 'packed'
|
int |
transformation method for integer vectors. Default: 'deltaframe'
|
fct |
transformation method for factors vectors. Default: 'packed'
|
dbl |
transformation method for doubles (and complex) vectors. Default: 'alp'
|
str |
transformation method for character vectors. Default: 'mega'
|
list |
transformation method for lists (and data.frames). Default: 'raw'
|
int_threshold, lgl_threshold, fct_threshold, dbl_threshold, str_threshold
|
Below this threshold, no transformation will be done. All default to 0, meaning transformation is always attempted. |
dbl_fallback |
if |
... |
expert level options |
named list
myopts <- zap_opts(dbl = 'shuffle') zap_write(seq(1:1000) * 1.5, opts = myopts)myopts <- zap_opts(dbl = 'shuffle') zap_write(seq(1:1000) * 1.5, opts = myopts)
Unserialize R object from raw vector or file
zap_read(src, opts = list(), ...)zap_read(src, opts = list(), ...)
src |
Serialization source - either a raw vector of filename. |
opts |
Named list of options. See |
... |
other named options to be included in |
Unserialized R object
raw_vec <- zap_write(head(mtcars)) head(raw_vec, 50) length(raw_vec) zap_read(raw_vec)raw_vec <- zap_write(head(mtcars)) head(raw_vec, 50) length(raw_vec) zap_read(raw_vec)
This version number is the same as the version number present in the header of the serialized data.
zap_version()zap_version()
Integer
zap_version()zap_version()
Serialize R object to raw vector or file
zap_write( x, dst = NULL, compress = Sys.getenv("zap_compress_default"), opts = list(), ... )zap_write( x, dst = NULL, compress = Sys.getenv("zap_compress_default"), opts = list(), ... )
x |
R object |
dst |
Serialization destination. Default: NULL means to return the raw vector. If a character string is given it is assumed to be the path to the output file. |
compress |
compression type. Default: 'zstd' if available, otherwise 'gzip'.
This is set in the 'zap_compress_default' environment variable after
being detected during package start.
Other valid values 'none',
'xz', 'bzip2'. Compression is done using |
opts |
Named list of options. See |
... |
other named options to be included in |
IF dst is NULL, then return a raw vector, otherwise data
is written to file and nothing is returned.
raw_vec <- zap_write(head(mtcars)) head(raw_vec, 50) length(raw_vec) zap_read(raw_vec)raw_vec <- zap_write(head(mtcars)) head(raw_vec, 50) length(raw_vec) zap_read(raw_vec)