compress_chunk: Compress a Chunk of Data

View source: R/RcppExports.R

compress_chunkR Documentation

Compress a Chunk of Data

Description

Compresses a given chunk of raw binary data using a pre-existing compressor object.

Usage

compress_chunk(compressorPtr, input_chunk)

Arguments

compressorPtr

An external pointer to an existing compressor object. This object is usually initialized by calling a different function like create_compressor().

input_chunk

A raw vector containing the uncompressed data that needs to be compressed.

Details

This function is primarily designed for use with a compressor object created by create_compressor(). It takes a chunk of raw data and compresses it, returning a raw vector of the compressed data.

Value

A raw vector containing the compressed data.

Examples

# Create a new compressor object for zlib -> wbts = 15
zlib_compressor <- create_compressor(wbits=31)
compressed_data <- compress_chunk(zlib_compressor, charToRaw("Hello, World"))
compressed_data <- c(compressed_data, flush_compressor_buffer(zlib_compressor))
decompressed_data <- memDecompress(compressed_data, type = "gzip")
cat(rawToChar(decompressed_data))

zlib documentation built on Oct. 19, 2023, 1:13 a.m.