| komp_decompress | R Documentation |
Decompress a raw vector
komp_decompress(
x,
codec = "auto",
max_output = getOption("zukomp.max_output", 1024^3),
max_ratio = getOption("zukomp.max_ratio", NULL)
)
x |
A raw vector holding a complete compressed stream. |
codec |
Codec name, as listed in |
max_output |
Refuse to produce more than this many bytes. Defaults
to 1 GiB, overridable with |
max_ratio |
Refuse to expand by more than this factor. |
A stream may hold several gzip members, or several zstd or LZ4 frames,
back to back; they decode as one, as the reference tools do. Anything
else after the end of the stream is an error of class
zukomp_trailing_bytes.
An lz4-block stream is one bare LZ4 block, which records neither its
decoded size nor where it ends. Decoding one therefore searches for the
size, bounded by max_output, and a block cut short can be a valid,
shorter block: nothing in the format can tell. Prefer lz4-frame
wherever the format is yours to choose.
A raw vector.
komp_compress(), komp_codecs()
z <- komp_compress(charToRaw(strrep("data ", 200)), "gzip")
rawToChar(komp_decompress(z, "gzip"))
# a small input that would expand a long way is stopped, not allocated
bomb <- komp_compress(raw(1e6), "gzip")
length(bomb)
try(komp_decompress(bomb, "gzip", max_output = 1024))
# zstd and lz4-frame streams are detected by their magic bytes
komp_decompress(komp_compress(charToRaw("hello"), "zstd"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.