snappier: Snappy compression and decompression

snappierR Documentation

Snappy compression and decompression

Description

Snappy is a fast compression library written by google and widely used in distributed systems.

This package provides bindings to the standard snappy implementation.

Usage

compress(chars)

compress_raw(raw)

decompress(raw)

decompress_raw(raw)

Arguments

chars

A character vector (of length 1) to compress with snappy.

raw

A raw vector (RAWSXP) to compress or decompress with snappy.

Details

These binding contain the snappy C++ code and necessary R wrappers, so there is no need to install or link to a snappy dynamic library (so or dll file) in order to use this package.

Furthermore, these binding work at the level or raw bytes, not character vectors, which is more robust and should be faster. Use compress_raw and decompress_raw when working with anything other than text.

compress and decompress provide wrappers around compress_raw and decompress_raw which convert R character vectors into the raw type needed by the underlying engine.

Value

compress returns the raw snappy encoded bytes of the text input.

compress_raw returns the raw snappy encoded bytes of the raw input.

decompress returns the a character vector made from the decoded bytes of its input. If this coercion can't be performed (i.e., the bytes can't be represented as a string) an error will be thrown.

decompress_raw returns the a raw bytes decoded from its input. When passed bytes which are not snappy compressed, this function will return NULL.

Examples

library(snappier)
# Roundtrip compression of character vector
decompress( compress( "this and that" ) ) # "this and that"

compress("")                              # 00
compress_raw(c())                         # 00

decompress_raw(0)                         # raw(0)
decompress(0)                             # ""


snappier documentation built on Sept. 19, 2022, 5:07 p.m.