deflate_compress: Compress a raw vector with libdeflate

View source: R/api.R

deflate_compressR Documentation

Compress a raw vector with libdeflate

Description

Compress the given raw vector using the specified libdeflate compressor.

Usage

deflate_compress(compressor, input)

Arguments

compressor

An external pointer created by 'alloc_compressor()'.

input

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

Value

A raw vector containing the DEFLATE‐compressed output.

Examples

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

libdeflate documentation built on June 29, 2025, 5:07 p.m.