Package 'lz4lite'

Title: Extremely Fast Compression and Serialization with LZ4
Description: 'LZ4' is an extremely fast compression standard with compression speeds of hundreds of megabytes per second, and decompression speeds of over a gigabyte per second. Use this package to compress data and serialize arbitrary objects to files or raw vectors.
Authors: Mike Cheng [aut, cre, cph], Yann Collet [cph] (Author of bundled lz4 code)
Maintainer: mikefc <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0
Built: 2026-05-20 09:32:52 UTC
Source: https://github.com/coolbutuseless/lz4lite

Help Index


Compress a raw vector

Description

Compress a raw vector

Usage

lz4_compress(src)

Arguments

src

raw vector to be compressed.

Value

raw vector of compressed data

Examples

src <- as.raw(rep(1L, 10000))
length(src)
enc <- lz4_compress(src)
length(enc)
result <- lz4_decompress(enc)
length(result)

Decompress a raw vector of compressed data

Description

Decompress a raw vector of compressed data

Usage

lz4_decompress(src)

Arguments

src

raw vector of compressed data created with lz4_compress()

Value

uncompressed vector

Examples

src <- as.raw(rep(1L, 10000))
length(src)
enc <- lz4_compress(src)
length(enc)
result <- lz4_decompress(enc)
length(result)

Serialize an R object to a file or raw vector

Description

Serialize an R object to a file or raw vector

Usage

lz4_serialize(x, dst = NULL, acc = 1L, dict = NULL)

lz4_unserialize(src, dict = NULL)

Arguments

x

An R object

dst

When std is a character, it will be treated as a filename. When NULL it indicates that the object should be serialized to a raw vector

acc

LZ4 acceleration factor (for compression). Default 1. Valid range [1, 65535]. Higher values mean faster compression, but larger compressed size.

dict

Dictionary to aid in compression. raw vector. NULL for no dictionary. create zstd --train dirSamples/* -o dictName --maxdict=64KB

src

data source for unserialization. May be a file name, or raw vector

Value

If dst is a file, then no value is returned. Otherwise returns a raw vector.

Examples

raw_vec <- lz4_serialize(mtcars)
head(raw_vec)
lz4_unserialize(raw_vec)