Learn R Programming

libdeflate (version 1.24-7)

deflate_compress: Compress a raw vector with libdeflate

Description

Compress the given raw vector using the specified libdeflate compressor.

Usage

deflate_compress(compressor, input)

Value

A raw vector containing the DEFLATE‐compressed output.

Arguments

compressor

An external pointer created by `alloc_compressor()`.

input

A raw vector (or object coercible to raw) containing the data to compress.

Examples

Run this code
# Low compression values might not compress at all
cmp = alloc_compressor(1L)
raw_in = charToRaw("Fast compression test: 1231231231231231")
raw_cmp_1 = deflate_compress(cmp, raw_in)
print(sprintf("Length in: %i Length out: %i", length(raw_in), length(raw_cmp_1) ))
# Max compression is 12
cmp = alloc_compressor(12L)
raw_cmp_12 = deflate_compress(cmp, raw_in)
print(sprintf("Length in: %i Length out: %i", length(raw_in), length(raw_cmp_12) ))

Run the code above in your browser using DataLab