compress_chunk {zlib} | R 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 |
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))
[Package zlib version 1.0.3 Index]